I have installed, say, jQuery:
npm install jquery
Now my site has
ROOT/node_modules/jquery/*
subdirectory.
What to do next? Just write
<script src="/node_modules/jquery/src/jquery.js"></script>
Or I can do something to take jquery.js
out this path and/or encode reference in some portable way?
For example, suppose I am using Jade template. Shoud I write just
script(src="/node_modules/jquery/src/jquery.js")
To answer your question shortly: yes, you can copy jquery.js
and move it to whatever folder you want. Then, you would have to change the src attribute in the script element, like this:
<script src="/new/path/jquery.js"></script>
However, in production cases, you would most likely want to join all the js files, and then only load a few files, like the following:
<script src="/path/libs.js"></script>
where libs.js
contains all of our dependencies in correct order.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With