0

Is there a way to include a single javascript file in a page, which in turn loads 1 or many node modules from an external source? that means it loads all JS and/or CSS files in that node module.

To say it in another way, I'd like users to include a single javascript file in their project, and that javascript file requires node modules to function. How do I achieve that?

Abdul
  • 231
  • 3
  • 14
  • 4
    Have you tried using `browserify`? – guest271314 Oct 10 '16 at 17:05
  • 2
    When you talk about node modules but in the same breath talk about css files you confuse me. Are these files supposed to be loaded within the browser client side? – Darkrum Oct 10 '16 at 17:07
  • @Darkrum i'm trying to to use [Shepherd](https://github.com/HubSpot/shepherd) which creates DOM elements with its own CSS that gets installed with `npm` and comes part of the `node_modules` package. – Abdul Oct 10 '16 at 17:11
  • you can create a npm package, and tell them to add your package to their project dependencies – ssbb Oct 10 '16 at 17:17
  • @guest271314 this seems to fit the bill, but will it allow me to load external modules that are not installed in the end user's machine? – Abdul Oct 10 '16 at 17:18
  • @ssbb This is exactly what I'm trying to avoid. if I know the devs on the project I have, they'll take a month to do anything more than adding a single tag to their HTML. – Abdul Oct 10 '16 at 17:19
  • @ssbb also, I would like to be able to change the referenced code at my end. – Abdul Oct 10 '16 at 17:24
  • _"but will it allow me to load external modules that are not installed in the end user's machine?"_ What do you mean? – guest271314 Oct 10 '16 at 17:24
  • @guest271314 meaning can I use browserify to require modules that are not part of the end user's environment? in other words, let's say whoever installs the script doesn't even have node installed, and I require a module, will that module run? – Abdul Oct 10 '16 at 17:28
  • @Abdul See [What is the difference between browserify/requirejs modules and ES6 modules](http://stackoverflow.com/q/28674652/) , [Task Runners (Gulp, Grunt, etc) and Bundlers (Webpack, Browserify). Why use together?](http://stackoverflow.com/q/33561272/) _"Webpack and Browserify are package bundlers. Basically, they are designed to run through all of a package's dependencies and concatenate their source into one file that (ideally) can be used in a browser."_ – guest271314 Oct 10 '16 at 17:35
  • 1
    @guest271314 Thanks for your help! I've got some education to do now. – Abdul Oct 10 '16 at 17:36

0 Answers0