简体   繁体   中英

Meteor script ensured to be executed before everything else (on Client)

I guess the topic of Meteor forcing execution order heuristics on its users instead of providing import semantics has been discussed to death already.

Nevertheless, I think there should at the very least be a way to make 100% sure that a certain set of scripts can be run before everything else. From what I understand, since the load order heuristic goes depth-first over everything else (even if you have multiple lib folders in different places, the ones at a greater depth are run first for some reason), there is basically no way to ensure that some scripts are executed before everything else, no matter how deep it goes, unless you put it in a package.

Is that correct? And is there anything to be expected to remedy the situation in an upcoming release?

For now, I am considering writing a little load-order-util package that at the very least allows deferring execution of a callback until startup and after a given set of globally defined symbols are ready, like so:

Global.dependsOnSymbols = function(symbolNameOrNames, cb) { ... };

Any better suggestions?

As you can realize by reading:

How do I change the order in which Meteor loads Javascript files?

and

In Meteor JS, how to control Javascript load order in relation to DOM load order? For animations

as things are right now, it is probably better to stick with the loading conventions offered by the framework itself.

Anyway, the upcoming 1.3 release should finally address the problem providing ES2015 modules support.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM