Stylesheet Injection

Working with Meteor/Flow Router, there is a certain page that I want a dynamic stylesheet file to be used. Pretty easily, I could do a css injection, but being new to Meteor, I feel like that is the wrong approach to dynamic css stylings on individual routes. So, to be clear, I have one page/route, that might load one of ten .css files on an individual basis. Is the best way to do this some sort of css file injection/replacement, or is it better to use the native import or require function?

I don’t think import supports this kind of dynamic loading. It would be simpler to use the standard JavaScript ways of doing it.

Something like this would be what I’d think (it’s jQuery).

  // Insert the sytle sheet
  $('head').append('<link rel="stylesheet" href="/packages/neo_reveal-js/reveal.js/css/theme/serif.css" type="text/css" id="theme" class="theme" />');

So then a css injection/replacement is ideal?

1 Like

Yeah that looks fine to me.