blakek / addtopage

Inject content to your page how you want—using JavaScript
MIT License
0 stars 0 forks source link

Make it easy to add libraries, e.g. from npm #18

Open blakek opened 7 years ago

blakek commented 7 years ago

With services like unpkg, we could load stuff from npm pretty easily. Maybe this should just be an option passed in?

Idea:

addtopage('moment', { npm: true }) // loads latest version of moment through http://unpkg.com/moment

If that's true, we'll also need some way of specifying which file to load for libraries where the "main" file isn't what we need when using addtopage.

Idea:

// just add it all here; most likely the easiest route since it's just appending the stuff to the unpkg URL
addtopage('react@15.3.1/dist/react.min.js', { npm: true })

// could use multiple options; probably only useful if a CDN other than unpkg is going to be used
addtopage('react', {
  npm: true,
  version: '15.3.1',
  file: '/dist/react.min.js'
})