Trần Kim Dự Trần Kim Dự - 1 year ago 104
CSS Question

Meteor: choose custom javascript and custom css for template

AFAIK, in Meteor, when compiling app, all javascript files and all css files will be merged to one file. I think this behavior will slow down app (because user must download all css and javascript that unnecessary for that page). Moreover, this behavior makes our app not dynamic, because maybe some page, we need different css or javascript files.

So my question is: How can we choose custom javascript and custom css for a template ? Does Meteor support this ?

Thanks :)

Answer Source

AFAIK Meteor is not supporting this exactly in that way. So you are left with two workarounds.
One would be writing a own extension which helps you in that regard or finding one which already exists.
And the other would be putting your special resources somewhere in the /yourMeteorApp/public folder which is excluded from the merge process (see And now you could write some template specific logic to load and evaluate JS and CSS resources from there when your template is accessed. Resources in public are available directly on root level - so public/js/my.js would be available under

This answer is quite old and in modern Meteor apps you should make use of the import logic (and the imports folder) which didn't exist in that way when I originally answered this:
This should be the best way to handle any dynamic JS requirements and strucutre an app by far nowadays.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download