stephenscaff / read-smore

A little Read More JS thing
https://stephenscaff.github.io/read-smore/
MIT License
28 stars 7 forks source link

Add CDN usage example (Not NPM) to the docs #14

Closed Ezra-Siton-UIX closed 2 years ago

stephenscaff commented 2 years ago

Hey!

All npm packages are included in unpkg CDN.

So, Read Smore is found at https://unpkg.com/read-smore which will resolve specifically to the latest umd version (currently) at https://unpkg.com/read-smore@2.0.4/dist/index.umd.js.

So, if you add the script to your project:

<script src="https://unpkg.com/read-smore@2.0.4/dist/index.umd.js"></script>

You can initialize it like:

const ReadSmore = window.readSmore

// target all read more elements
const readMoreEls = document.querySelectorAll('.js-read-smore')

// Init
ReadSmore(readMoreEls).init()

And you're gtg.

Here's a CodePen example

I suppose I can also update the ReadMe / Docs.

Thanks.

Ezra-Siton-UIX commented 2 years ago

Thanks!!