Gathering detailed insights and metrics for smoothscroll-anchor-polyfill
Gathering detailed insights and metrics for smoothscroll-anchor-polyfill
Gathering detailed insights and metrics for smoothscroll-anchor-polyfill
Gathering detailed insights and metrics for smoothscroll-anchor-polyfill
postcss-smoothscroll-anchor-polyfill
PostCSS plugin that updates the standard scroll-behavior property to work with smoothscroll-anchor-polyfill
react-anchor-link-smooth-scroll
React component for anchor links using the smoothscroll polyfill.
react-anchor-link-smooth-scroll-ts
React component for anchor links using the smoothscroll polyfill.
react-anchor-link-smooth-scroll-v2
React component for anchor links using the smoothscroll polyfill.
⚓ Apply smooth scroll to anchor links, polyfill scroll-behavior
npm install smoothscroll-anchor-polyfill
Typescript
Module System
80.4
Supply Chain
100
Quality
76.1
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
507,070
Last Day
125
Last Week
2,623
Last Month
11,310
Last Year
93,416
MIT License
42 Stars
133 Commits
4 Forks
1 Watchers
2 Branches
2 Contributors
Updated on May 26, 2025
Minified
Minified + Gzipped
Latest Version
1.3.4
Package Id
smoothscroll-anchor-polyfill@1.3.4
Unpacked Size
57.96 kB
Size
13.90 kB
File Count
10
Cumulative downloads
Total Downloads
Last Day
204.9%
125
Compared to previous day
Last Week
66.1%
2,623
Compared to previous week
Last Month
-10.3%
11,310
Compared to previous month
Last Year
14.5%
93,416
Compared to previous year
⚓ Apply smooth scroll to anchor links to polyfill the CSS property scroll-behavior
⚠ Requires smooth scroll for window.scroll()
and Element.scrollIntoView()
(e.g. smoothscroll-polyfill) to work!
![]() IE / Edge | ![]() Firefox | ![]() Chrome | ![]() Safari | ![]() iOS Safari | ![]() Opera |
---|---|---|---|---|---|
IE9+, Edge | native | native* | last 2 versions | last 2 versions | native* |
* hashchange navigation triggered by forwards/backwards buttons isn't smooth despite native support. Learn more
scroll-behavior: smooth
in CSS⚠ Has to be set global (on
html
), check the docs for limitations
Because CSS properties unknown to a browser can't efficiently be parsed from JavaScript, just specyfing the normal scroll-behavior
property is not enough unfortunately.
You need to add an additional CSS variable so the polyfill can read it:
1html { 2 --scroll-behavior: smooth; 3 scroll-behavior: smooth; 4}
You can also use media queries, toggle classes etc. to control the smooth scroll. The following only enables smooth scroll on Desktop devices, for example:
1html { 2 --scroll-behavior: auto; 3 scroll-behavior: auto; 4} 5 6@media screen and (min-width: 1150px) { 7 html { 8 --scroll-behavior: smooth; 9 scroll-behavior: smooth; 10 } 11}
💡 This process can be automated using a PostCSS plugin, so you can write regular CSS and it'll be transformed to work with the polyfill automatically.
The plugin will also read your browserslist and choose the right transformation depending on if all your browsers support CSS variables or not. It just works™
Legacy browsers like Internet Explorer do not support CSS variables, so you need another way to specify scroll-behavior
. There are two options:
style
attribute1<html style="scroll-behavior: smooth;"> 2 ... 3</html>
font-family
Alternatively, you can specify the property as the name of a custom font family. Your actual fonts will still work the way they should (plus, you can simply declare actual fonts on body
). As with CSS variables (and unlike inline styles), this allows you to use normal CSS features like media queries.
1<style> 2 html { 3 scroll-behavior: auto; 4 font-family: 'scroll-behavior: auto;', 'Roboto', sans-serif; 5 } 6</style>
Because this polyfill only wires up anchor links to use the browser's native window.scroll()
and element.scrollIntoView()
methods, you'll need to load a polyfill providing smooth scroll to these methods in addition to the steps outlined below.
smoothscroll-polyfill works, but you can just as well use another one or write your own implementation. Learn More
1<script src="https://unpkg.com/smoothscroll-anchor-polyfill"></script>
1npm install smoothscroll-anchor-polyfill
then
1import 'smoothscroll-anchor-polyfill'
The full documentation with advanced installation instructions, limitations, features like enabling and disabling the smooth scrolling and more can be found at
jonaskuske.github.io/smoothscroll-anchor-polyfill.
The documentation site itself is built as a smooth scrolling one-page design, utilizing this polyfill.
PRs welcome!
© 2021, Jonas Kuske
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/9 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
36 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-02
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More