Load order rules for Meteor


#1

imkost:load-order package allows to:

  • Create file load order rules
  • Create rules for separating client and server code

http://github.com/imkost/load-order


Want starter.js and reset.css files to be loaded before others?

loadOrder.config.getLoadOrderIndex = function(filepath, filename) {
  if (filename === 'application-starter.js' || filename === 'reset.css') {
    return 0;
  }

  return 1;
}

Want *.client.js files to be served only to client and *.server.js files to server?

loadOrder.config.getLocus = function(filepath, filename, ext) {
  if (ext === 'js') {
    if (filename.indexOf('.client.js') >= 0) {
      return 'client';
    }

    if (filename.indexOf('.server.js') >= 0) {
      return 'server';
    }
    
    return 'shared';
  }

  return 'client';
}

Want CSS for elements (person__name.css, person__address.css) to be loaded after CSS for blocks (person.css)?

loadOrder.config.getLoadOrderIndex = function(filepath, filename, ext) {
  if (ext === 'css' && filename.indexOf('__') >= 0) {
    return 1;
  }

  return 0;
}

#2

Does this only change load order of any .js files that would usually be loaded after all the packages are loaded or will all .js, .less, etc. files be loaded via the package, meaning you can truly change load order and even load stuff before other packages get loaded? Or at least seperate super crucial .js files to be loaded before others?

Is it also possible to define load order of html imports?


#3

It’s all explained here http://github.com/imkost/load-order.

All of your code will be executed after packages. And you can’t make super crucial .js to be loaded before packages.

I never used html imports, so I’m not sure about this. Anyway, you can change load order of html files.