Here’s how I think of it:
Your application is run within the browser, but it also requires the Meteor object. The
Meteor object is like a large balloon inside a box. Absent other objects within your box, if you blow up the balloon, it will expand to take the shape of the box (minus a little space in the corners). Similarly, absent things that one has attached to the
window object, the
Meteor object is proportionately the entirety of your application.
Meteor object isn’t a balloon. To use a car analogy, it’s the chasis and frame of your car. And that makes the
Meteor.startup() method like the ignition system in your car.
Using that analogy, it’s possible to replace the tires on a car or change the oil without having the car engine ignited, right? That’s what’s happening when you see that Templates are getting rendered before the Meteor.startup().
Meteor object gets attached to the
window object, but so does the
Template objects. Which means that there’s a bit of chance that they can get initialized before
Meteor does, and start to process things. But a tire or a bottle of oil don’t drive themselves. Without the
Meteor object, they just kind of sit there, waiting for the app to initialize. But when the
Meteor object initializes, and then the
Meteor.startup() is called, everything starts up and the Templates get picked up and put into place; the data subscriptions get data to the client, and the templates can finally render correctly.
To the extent that minimongo is a client-side Mongo replica set, this can also be considered database flapping, by the way. (Being reactive, the templates will sometimes flap a bit before the data subscriptions get populated and they have data to grab onto. This can be managed with defensive programming techniques.)
I documenting this in the Event Cycle page back in the 0.7 days, and have tried to keep it up to date during the subsequent API changes. I’m not sure how well this explains things, or how accurate it really is, but it should hopefully sort of explain things.
Meteor Event Cycle - Advanced
Also, take the term ‘render’ with a grain of salt. It’s not rendering in the sense of the term that animators or video device drivers use the term. It’s not rendering in the sense of a double-buffered render graphics pipeline. As I understand it, It’s ‘render’ more in the sense of ‘assemble a DOM tree’.