PHPackages                             hk2/scrolltop - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hk2/scrolltop

ActiveMagento2-module[Utility &amp; Helpers](/categories/utility)

hk2/scrolltop
=============

Scroll Top adds an intuitive icon at the bottom-right corner of each page so that with one click you will be at the top of the page. No more dragging of the scroll bar. It will be just fun and ergonomic to use. Scroll Top is an uncomplicated free Open Source Magento Module allowing site visitors to immediately and seamlessly get back to the top of your web page after scrolling a lengthy pages.

110ShellCI passing

Since Jun 8Pushed 3w ago2 watchersCompare

[ Source](https://github.com/basantmandal/magento2-scrolltop-module)[ Packagist](https://packagist.org/packages/hk2/scrolltop)[ RSS](/packages/hk2-scrolltop/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (7)Dependencies (1)Versions (5)Used By (0)

[![Version](https://camo.githubusercontent.com/ea9ef426d7257249967444fc38f23d854e483b614a19030e12feb17fa0bb5ff5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d312e302e302d626c75653f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/ea9ef426d7257249967444fc38f23d854e483b614a19030e12feb17fa0bb5ff5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d312e302e302d626c75653f7374796c653d666c61742d737175617265)[![Magento](https://camo.githubusercontent.com/cc7afc3a994043bd5e1bbe18fdecdf4377481f03e2dc7a05728c3174c7da66bf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d6167656e746f2d322e342e782d6639373331363f7374796c653d666c61742d737175617265266c6f676f3d6d6167656e746f266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/cc7afc3a994043bd5e1bbe18fdecdf4377481f03e2dc7a05728c3174c7da66bf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d6167656e746f2d322e342e782d6639373331363f7374796c653d666c61742d737175617265266c6f676f3d6d6167656e746f266c6f676f436f6c6f723d7768697465)[![PHP](https://camo.githubusercontent.com/2f2d39f30d9a245b748ead3268e5de0819ddab6c31a393904a4f33652b504e79/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d3763336165643f7374796c653d666c61742d737175617265266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/2f2d39f30d9a245b748ead3268e5de0819ddab6c31a393904a4f33652b504e79/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d3763336165643f7374796c653d666c61742d737175617265266c6f676f3d706870266c6f676f436f6c6f723d7768697465)[![License](https://camo.githubusercontent.com/a3fd2257982f64afbde00a66a8ab5984ee3f6e176f00eb2ec4ea61d862bc113b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4f534c2d2d332e302d677265656e3f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/a3fd2257982f64afbde00a66a8ab5984ee3f6e176f00eb2ec4ea61d862bc113b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4f534c2d2d332e302d677265656e3f7374796c653d666c61742d737175617265)[![Packagist](https://camo.githubusercontent.com/cf77e7b4cd725098d947bd0f8e298a213c4174ea05e6df07b886cf35e576a885/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f686b322f7363726f6c6c746f703f7374796c653d666c61742d737175617265)](https://packagist.org/packages/hk2/scrolltop)
[![Website](https://camo.githubusercontent.com/48510337f411c7e193a31e9bdb6802d49664918dac999471dcc705c9a94fa031/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f576562736974652d3030303f7374796c653d666c61742d737175617265266c6f676f3d6b6f2d6669266c6f676f436f6c6f723d7768697465)](https://www.basantmandal.in/)[![LinkedIn](https://camo.githubusercontent.com/f47f622117d99af4d0fcba939449e0949d2301d48601b78a25b6e7e1cf580d3e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c696e6b6564496e2d3041363643323f7374796c653d666c61742d737175617265266c6f676f3d6c696e6b6564696e266c6f676f436f6c6f723d7768697465)](https://www.linkedin.com/in/basantmandal/)[![Email](https://camo.githubusercontent.com/4fb7fe62859d942d68ae2f48af7c8fb6165e8f1dc236fa5bbc970e01efff28ef/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f456d61696c2d737570706f7274253430626173616e746d616e64616c2e696e2d626c75653f7374796c653d666c61742d737175617265266c6f676f3d676d61696c)](mailto:support@basantmandal.in)

---

HK2 ScrollTop - Adds "back to top" button to your storefront
============================================================

[](#hk2-scrolltop---adds-back-to-top-button-to-your-storefront)

**HK2\_ScrollTop** adds an intuitive icon at the bottom-right corner of each page so that with one click you will be at the top of the page. No more dragging of the scroll bar.

---

Overview
--------

[](#overview)

**HK2 ScrollTop** is a lightweight, pure-frontend Magento 2 module that adds a smooth "back to top" button to your storefront. Visitors can return to the top of long pages with a single click — no dragging, no fuss. Built entirely with CSS and JavaScript, it has zero backend PHP class overhead.

---

Problem Statement
-----------------

[](#problem-statement)

Long product pages, category listings, and CMS pages force users to manually scroll back to the top — or reach for the scrollbar — every time they want to access the main navigation, search bar, or header links. This friction degrades the user experience, especially on mobile devices where scrolling long distances is cumbersome.

---

Solution Approach
-----------------

[](#solution-approach)

HK2\_ScrollTop injects a fixed-position button at the bottom-right corner of every page. After the user scrolls past 20px, the button fades in. Clicking it triggers a smooth jQuery animation that scrolls the viewport to the top. The module requires no PHP Blocks or Models — it uses only layout XML, a CSS file, and a JavaScript file, all gated behind a single admin configuration toggle.

---

Who is this for?
----------------

[](#who-is-this-for)

- Magento 2 store owners who want a simple, unobtrusive scroll-to-top button
- Developers looking for a zero-configuration, no-PHP-backend module
- Shops with long product descriptions, tall category pages, or extensive CMS content

---

Use Cases
---------

[](#use-cases)

- **Long product pages** — After reading a detailed description, users can jump back to the Add to Cart button and header
- **Extended category listings** — Infinite-scroll or paginated lists where the top navigation is far away
- **CMS pages** — About Us, Terms &amp; Conditions, FAQ, and blog posts benefit from quick top-of-page access
- **Mobile storefronts** — Eliminates tedious thumb-scrolling on tall mobile layouts

---

Key Features
------------

[](#key-features)

- **One-click scroll-to-top** — Smooth jQuery animation back to the page top
- **Lightweight, no-PHP design** — Zero Block/Model classes; only CSS, JS, and layout XML
- **Responsive fixed-position** — Stays at the bottom-right corner across all viewports
- **Smooth animation** — Fade-in/fade-out based on scroll position, with animated scroll
- **Configurable enable/disable** — Toggle on/off via admin configuration (enabled by default)

---

Architecture Overview
---------------------

[](#architecture-overview)

```
Layout XML (default_head_blocks.xml)
├── head.additional → header.phtml → scrollTop.css (injected into )
└── before.body.end → footer.phtml → button HTML + scrollTop.js (injected before )

Configuration
└── Stores → Configuration → HK2 → ScrollTop_Configuration
    └── Enable/Disable toggle (ifconfig gating both layout blocks)

```

The module has **no PHP Block or Model classes**. All frontend behaviour is driven by:

- `view/frontend/layout/default_head_blocks.xml` — Layout handle with `ifconfig`-gated blocks
- `view/frontend/templates/header.phtml` — CSS link injection
- `view/frontend/templates/footer.phtml` — SVG button markup and JS script tag
- `view/frontend/web/css/scrollTop.css` — Fixed-position styling (41x41px, dark background, yellow icon)
- `view/frontend/web/js/scrollTop.js` — jQuery-based scroll detection and animation

---

System Requirements
-------------------

[](#system-requirements)

RequirementVersionMagentoOpen Source 2.4.x / Commerce 2.4.xPHP^8.1 || ^8.2 || ^8.3 || ^8.4Composer2.xDependencies`hk2/core ^1.0`, `magento/framework ^103.0.0`---

Installation
------------

[](#installation)

```
composer require hk2/scrolltop
php bin/magento module:enable HK2_ScrollTop
php bin/magento setup:upgrade
php bin/magento cache:clean
```

See [docs/installation.md](docs/installation.md) for detailed setup instructions.

---

Configuration
-------------

[](#configuration)

1. Navigate to **Stores → Configuration → HK2 → ScrollTop\_Configuration**
2. Set **Enable ScrollTop** to **Yes** (default)
3. Save configuration and clear the cache

Alternatively, use the menu shortcut at **Content → HK2 - Scroll Top**.

The enable/disable toggle controls both the CSS and JS injection via the `ifconfig` attribute in the layout XML. When disabled, no markup, styles, or scripts are added to the page.

---

Content Security Policy (CSP)
-----------------------------

[](#content-security-policy-csp)

The module loads its CSS and JS from local Magento static files (`HK2_ScrollTop::css/scrollTop.css` and `HK2_ScrollTop::js/scrollTop.js`). No external resources, CDN scripts, or inline styles/scripts are injected, making the module fully CSP-compatible out of the box.

No CSP whitelist entries are required.

---

Privacy &amp; GDPR
------------------

[](#privacy--gdpr)

HK2\_ScrollTop does **not**:

- Collect, store, or transmit any personal data
- Set cookies or use local/session storage
- Track user behaviour or page views
- Send data to any third-party service

The module is fully GDPR-compliant. No consent notices or privacy policy updates are needed.

---

Documentation
-------------

[](#documentation)

- [Installation Guide](docs/installation.md)
- [Usage Guide](docs/usage.md)
- [Compatibility Information](docs/compatibility.md)
- [Changelog](CHANGELOG.md)
- [Security Policy](SECURITY.md)

---

Known Limitations
-----------------

[](#known-limitations)

- **No custom styling options in admin** — Button colours, size, and position cannot be changed via the admin panel; CSS overrides from a custom theme are required for visual customisation
- **Always bottom-right** — The button is fixed to the bottom-right corner (right: 15px, bottom: 6px) and cannot be repositioned via configuration
- **jQuery dependency** — Requires jQuery (bundled with Magento); not available as a vanilla JS implementation

---

Contributing
------------

[](#contributing)

Contributions are welcome. Please open an issue or pull request on the [GitHub repository](https://github.com/anomalyco/opencode). For bug reports, use the provided issue template.

---

License
-------

[](#license)

This software is licensed under the Open Software License (OSL 3.0). See [LICENCE.txt](LICENCE.txt) for the full license text.

---

Disclaimer
----------

[](#disclaimer)

THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance62

Regular maintenance activity

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 Bus Factor1

Top contributor holds 98% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~462 days

Total

3

Last Release

555d ago

PHP version history (2 changes)1.0.0PHP ^7.3.0|^7.4.0|^8.0|^8.1.0

1.1.0PHP ^7.3.0|^7.4.0|^8.0|^8.1.0|^8.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ffa270f1557c4c55c55fec1ad6f2544170980c8dd7f679c10582a3736f7d3a4c?d=identicon)[basantmandal](/maintainers/basantmandal)

---

Top Contributors

[![basantmandal](https://avatars.githubusercontent.com/u/69835601?v=4)](https://github.com/basantmandal "basantmandal (48 commits)")[![semantic-release-bot](https://avatars.githubusercontent.com/u/32174276?v=4)](https://github.com/semantic-release-bot "semantic-release-bot (1 commits)")

---

Tags

hk2magento2magento2-extension-freemagento2-module-free

### Embed Badge

![Health badge](/badges/hk2-scrolltop/health.svg)

```
[![Health](https://phpackages.com/badges/hk2-scrolltop/health.svg)](https://phpackages.com/packages/hk2-scrolltop)
```

###  Alternatives

[elgentos/regenerate-catalog-urls

Regenerate Catalog URL Rewrites (products, categories, cms pages)

2842.6M](/packages/elgentos-regenerate-catalog-urls)[nosto/module-nostotagging

Increase your conversion rate and average order value by delivering your customers personalized product recommendations throughout their shopping journey.

27703.7k4](/packages/nosto-module-nostotagging)[tig/postnl-magento2

TIG Magento 2 PostNL extension

59570.5k5](/packages/tig-postnl-magento2)[myparcelnl/magento

A Magento 2 module that creates MyParcel labels

1860.2k](/packages/myparcelnl-magento)[loki/magento2-components

Core module for defining Alpine.js components with advanced AJAX features

1011.8k26](/packages/loki-magento2-components)[zwernemann/module-withdrawal

Magento 2 EU Withdrawal Button Module - Adds a withdrawal/revocation button for orders in compliance with EU Directive (EU) 2023/2673

244.8k2](/packages/zwernemann-module-withdrawal)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
