n00b n00b - 1 year ago 133
CSS Question

Meteor load scripts, CSS specific to pages

The problem I'm currently experiencing is, that I want to be able to execute only specific scripts and CSS files, because if executed on a wrong page, it produces errors in the browser console.

I'm using "Iron router" for Meteor with only the basic code to make it work. Now, is there a way for me to send scripts as parameters, so it only loads the ones I want the page to load?

Answer Source

In short, there isn't. (Yet.)

You probably have a wrong code structure if you've got errors. There are ways to execute code only when it's needed - you should probably take a look at template.rendered and template.created callbacks, as well as iron router controllers. However, that's for execution - everything is loaded on the beginning.

That being said, you technically could use things like require.js to load some scripts dynamically. But this negates most of Meteor's advantages. It's also quite difficult to make it work properly with Meteor.

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