0
votes

I am new to Meteor and in-fact in learning stage. I am working on a project, in which I have two views Front-end and Back-end(Dashboard).

I want to ask multiple things regarding the best way of loading external scripts in Meteor so that it runs fast.

  1. Where to load the external script in Meteor so that application runs like a bullet, mean in template or in template's helper. (Currently I am loading scripts in templates by using script tags in it like <template name="myTemplate"><script>Loads any JS file</script></template> )

  2. What should be best way to load scripts fast that are dependent on each other in a theme.

  3. How can I separate load CSS & JS files for front-end and back-end so that front-end files should not interrupt/load in back-end and back-end file should not interrupt/load in front-end

1
Have you tried reading this entry in the docs docs.meteor.com/#/full/structuringyourapp already? - Sceptic
Yes, I did read that, but that is about the structure of the meteor app but I am asking about the code that where to put the JS scripts so that it runs fast - Najam-us-Saqib
Any CSS and JS that's inside of the client folder will get minified and added to every single page in your web app. There's also no control of load order in relation to the DOM. You can also put your CSS and JS inside the public folder and refer to them via standard script and link tags. - fuzzybabybunny

1 Answers

1
votes

If you load a script in the

    <head></head>

you won't run into any problems with Meteor. Generally thats the best way to do it. Same thing with your CSS files. If for some reason you need to load a script tag in the body, check out this article that describes two ways.

http://www.kaplankomputing.com/blog/tutorials/two-ways-to-add-a-script-tag-in-meteor/