Skip to content

Commit b64d4fd

Browse files
committed
Updated the readme
1 parent 902c26c commit b64d4fd

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

README.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,31 @@ There are two versions of Smooth Scroll: the standalone version, and one that co
2222

2323
If you're including your own polyfills or don't want to enable this feature for older browsers, use the standalone version. Otherwise, use the version with polyfills.
2424

25-
**Direct `<script>` include**
25+
**Direct Download**
2626

27-
[Download the files directly](https://github.com/cferdinandi/smooth-scroll/archive/master.zip) or use the [jsDelivr CDN](https://cdn.jsdelivr.net/gh/cferdinandi/smooth-scroll/dist/).
27+
You can [download the files directly from GitHub](https://github.com/cferdinandi/smooth-scroll/archive/master.zip).
2828

2929
```html
30-
<!-- Direct Download -->
3130
<script src="path/to/smooth-scroll.polyfills.min.js"></script>
32-
33-
<!-- CDN -->
34-
<script src="https://cdn.jsdelivr.net/gh/cferdinandi/[email protected]/dist/smooth-scroll.polyfills.min.js"></script>
3531
```
3632

37-
**NPM**
33+
**CDN**
34+
35+
You can also use the [jsDelivr CDN](https://cdn.jsdelivr.net/gh/cferdinandi/smooth-scroll/dist/). I recommend linking to a specific version number or version range to prevent major updates from breaking your site. Smooth Scroll uses semantic versioning.
36+
37+
```html
38+
<!-- Always get the latest version -->
39+
<!-- Not recommended for production sites! -->
40+
<script src="https://cdn.jsdelivr.net/gh/cferdinandi/smooth-scroll/dist/smooth-scroll.polyfills.min.js"></script>
3841

39-
```bash
40-
npm install smooth-scroll
42+
<!-- Get minor updates and patch fixes within a major version -->
43+
<script src="https://cdn.jsdelivr.net/gh/cferdinandi/smooth-scroll@14/dist/smooth-scroll.polyfills.min.js"></script>
44+
45+
<!-- Get patch fixes within a minor version -->
46+
<script src="https://cdn.jsdelivr.net/gh/cferdinandi/[email protected]/dist/smooth-scroll.polyfills.min.js"></script>
47+
48+
<!-- Get a specific version -->
49+
<script src="https://cdn.jsdelivr.net/gh/cferdinandi/[email protected]/dist/smooth-scroll.polyfills.min.js"></script>
4150
```
4251

4352
### 2. Add the markup to your HTML.
@@ -65,6 +74,20 @@ In the footer of your page, after the content, initialize Smooth Scroll by passi
6574
***Note:*** *The `a[href*="#"]` selector will apply Smooth Scroll to all anchor links. You can selectively target links using any other selector(s) you'd like. Smooth Scroll accepts multiple selectors as a comma separated list. Example: `'.js-scroll, [data-scroll], #some-link'`.*
6675

6776

77+
## ES6 Modules
78+
79+
Smooth Scroll does not have a default export, but does support CommonJS and can be used with native ES6 module imports.
80+
81+
```js
82+
import('/path/to/smooth-scroll.polyfills.min.js')
83+
.then(function () {
84+
var scroll = new SmoothScroll('a[href*="#"]');
85+
});
86+
```
87+
88+
It uses a UMD pattern, and should also work in most major module bundlers and package managers.
89+
90+
6891

6992
## Working with the Source Files
7093

0 commit comments

Comments
 (0)