How to load 3rd party javascript when behind /import

well I know there have been a lot of similar topics - but as I can see non who answer the question: “How to load 3rd party Javescripts when behind /imports folder”
I want to use a good old jquery script - say “jquery.myLostScripts.min.js” - the script is not an atmosphere or a npm packages. I don’t want to use cdn in the head - because that a lot of pay load to carry (maybe with 20-30 scripts) .
So please - where do I store the scripts (using a /lib in the /imports) ???
and how do I import and load them in my /imports/ components/templates ???
I know they will interact with the DOM but there must be a way to lazy load those jquery/javascripts

Have you tried sticking them in /imports/lib/ (or /imports/vendor/ etc.) and just importing them?

As long as they don’t require global scope, they should work fine. I do this fairly often
Are you having any issues in particular?

Hi coagmano
Thanks for reply. Actually I had tried to place scripts in a /imports/scripts folder but i did not have much success. Maybe because of the scope - to many templates nested. I tried a simple one and it worked. I do appreciate your time - thanks.

1 Like