In my case it is angular and my application code has a lot of angular.module(…) and so on, I could wrap everything in Metoer.startup but I think I will also slow down the process, wouldn’t it?
Sorry not deep enough knowledge of Angular. Just in general I would not assume that elements are in the html file at the top. I would try to wait like a subscription for it to become reactively available. There is no slowdown because it can start when it’s ready. Thing is you needs some kind of loaded event / reactivity to attach your code in.
This seems like a quite clean implementation of waiting until something is loaded:
mplate.listing.onRendered(function () {
var template = this;
template.subscribe('listOfThings', function () {
// Wait for the data to load using the callback
Tracker.afterFlush(function () {
// Use Tracker.afterFlush to wait for the UI to re-render
// then use highlight.js to highlight a code snippet
highlightBlock(template.find('.code'));
});
});
});