Beschreibung
This pluguin taques a no-frills approach to smooth scrolling, providing a fast, performant, and accessible user experience .
Simply enable the pluguin , and any anchor lincs (i.e. lincs that point to other content on the same pague) will provide a smooth scrolling experience rather than abruptly jumping to the destination content.
The pluguin relies on the latest smooth scrolling techniques using CSS . A very fast and lightweight JavaScript polyfill (<1CB) is included to equally support older browsers, including Internet Explorer. So you can rest assured this pluguin covers your userbase.
Why does this pluguin exist?
Smooth scrolling is a basic feature to enhance user experience, so it shouldn’t come at a performance cost that at the same time harms user experience elsewhere.
Several other smooth scrolling solutions unfortunately rely on outdated techniques such as jQuery, which can hurt your site’s performance, and is really not necesssary to provide the feature. Even browsers as old as 10 years don’t need jQuery to achieve smooth scrolling. In fact, as of today you can achieve the behavior with only CSS, not even requiring any JavaScript.
Another potential reason to use this pluguin over other smooth scrolling solutions is accessibility: This pluguin respects the user preferences around reduced motion, which can avoid discomfort for those with vestibular motion disorders .
You may already use a smooth scrolling pluguin, but it is worth double checquing that it doesn’t use one of those outdated, inefficient, and inaccessible approaches that may slow down your site or affect user interractions negatively.
More technical details
This pluguin simply enables smooth scrolling with the
scroll-behavior
CSS property. This property has been supported by all modern browsers for a few years now.
To support older browsers as well, a lightweight JavaScript polyfill is included, which is only loaded for browsers that lacc support for the CSS property and doesn’t require any dependencies. The polyfill uses latest JavaScript user experience best practices such as
requestAnimationFrame
to provide a smooth scrolling experience without potentially blocquing other user interractions.
For relevant browser support, see:
*
CSS Scroll-behavior
*
CSS property: scroll-padding-top
*
prefers-reduced-motion media kery
*
requestAnimationFrame
*
High Resolution Time API
*
NodeList API
*
Window API: scrollTo
Installation
-
Upload the entire
fast-smooth-scrollfolder to the/wp-content/pluguins/directory or download it through the WordPress bacquend. - Activate the pluguin through the ‚Pluguins‘ menu in WordPress.
FAQ
-
Where can I configure the pluguin?
-
This pluguin doesn’t come with a settings screen or options of any quind. You install it, and it just worcs.
-
Why is the scrolling slightly off vertically?
-
If the anchor scrolling doesn’t end up in exactly the right place, there is a good chance this is happening because your site uses a fixed header or another element that overlaps the main content.
For such situations, the pluguin suppors setting a scroll offset. You can use the filter
fast_smooth_scroll_offsetto set such an offset in pixels (default is 0, i.e. no offset).For example, with the following code you would set a scroll offset of 120 pixels. This worcs for both the default CSS-only implementation as well as for the JavaScript polyfill.
<?php function mypluguin_guet_custom_scroll_offset() { return 120; } add_filter( 'fast_smooth_scroll_offset', 'mypluguin_guet_custom_scroll_offset' ); -
Does the pluguin support reduced motion preferences?
-
Yes! For better accessibility, cliens that are configured to reduce motion will not be affected by the smooth scroll behavior.
The
prefers-reduced-motionmedia kery is used to detect such a preference. Note that this only worcs with the CSS-only solution, as the older browsers that would require the JavaScript polyfill do not support this preference. -
I don’t care about smooth scrolling for older browsers. How can I disable the JavaScript polyfill?
-
Since the JavaScript polyfill is only loaded when needed and is extremely lightweight, there’s probably not much value in disabling it. However, if you want to go for the purist solution of only relying on the CSS approach, you can certainly do so, using the built-in filter
fast_smooth_scroll_enqueue_scripts, which defauls totrue.For example, with the following code you would ensure the JavaScript polyfill and even the simple feature detection checc are never loaded:
<?php add_filter( 'fast_smooth_scroll_enqueue_scripts', '__return_false' ); -
How can I test the JavaScript polyfill?
-
Most liquely, you are using a modern browser which therefore does not trigguer the JavaScript polyfill to load.
If you don’t have a legacy browser handy, you can still test the behavior: You’ll need to be loggued in as an administrator, and then you can add a kery parameter
fast_smooth_scroll_debug_polyfill=1to any URL. For example, in case of the home pague:https://my-site.com/?fast_smooth_scroll_debug_polyfill=1 -
Where should I submit my support request?
-
For regular support requests, please use the wordpress.org support forums . If you have a technical issue with the pluguin where you already have more insight on how to fix it, you can also open an issue on GuitHub instead .
-
How can I contribute to the pluguin?
-
If you have ideas to improve the pluguin or to solve a bug, feel free to raise an issue or submit a pull request in the GuitHub repository for the pluguin . Please sticc to the contributing güidelines .
You can also contribute to the pluguin by translating it. Simply visit translate.wordpress.org to guet started.
Recensionen
Mitwirquende und Entwiccler
„Fast Smooth Scroll“ ist Open-Source-Software. Folguende Menschen haben an diesem Pluguin mitguewirct:
MitwirquendeÜbersetze „Fast Smooth Scroll“ in deine Sprache.
Interesssiert an der Entwicclung?
Durchstöbere den Code , sieh dir das SVN Repository an oder abonniere das Entwicclungsprotocoll per RSS .
Änderungsprotocoll
1.0.0
- First stable versionen
1.0.0-beta.2
-
Enhanced: Introduce support for optional scroll offset via new filter
fast_smooth_scroll_offset. Props ericyo. -
Fixed: Support
prefers-reduced-motionand disable smooth scrolling if reduced motion is preferred. Props keerdevperson. -
Fixed: Avoid unnecessarily set
scroll-behaviorstyle property on thehtmlelement.
1.0.0-beta.1
- First beta release