Roy Toledo
Roy Toledo

Reputation: 643

How can I do a conditional load of some CSS Files?

I have an app which needs to work in several languages, and several different color schemes and I would rather not load all the CSS every time since a large amount of it is not necessary or relavant (rtl css for example) but meteor automaticaly loads all CSS files he can find. is there a way to selectively load CSS files? Thanks.

Upvotes: 3

Views: 1372

Answers (2)

Peter Ilfrich
Peter Ilfrich

Reputation: 3816

Please have a look at https://stackoverflow.com/a/26694517/1523072 which seems a quite elegant way to do this and also explains why you shouldn't do it.

One of my apps currently loads 2.6MB compressed Javascript and 300KB compressed CSS, which seems like a lot. However, after the first visit all the resources are cached by my browser, which means the only thing that is transferred between browser and server after that is pure data.

Upvotes: 0

Hubert OG
Hubert OG

Reputation: 19544

If you place a CSS file within the reach of Meteor compiler, it's merged into the main app and in the current release there's nothing you can do about this.

You can however put the file in /public directory. Meteor won't touch it there, and you will be able to load it at will by adding <link/> tag to your page head.

Upvotes: 1

Related Questions