Hacker News new | ask | show | jobs
by jashkenas 5243 days ago
So, the reason why you want to bootstrap the models you need for an initial render, directly into the page ... instead of doing this:

    myApp.init = function() {
      Books.fetch();
      Authors.fetch();
      Notes.fetch();
      ...
    };
... is because, all else being equal, it will noticeably improve the speed of your initial page load. Instead of N separate HTTP requests, all of your model data is available in the same HTTP request that fetches the HTML. Put the bootstrap at the bottom of your page, and you're in pretty good shape.
1 comments

Depending on the other content of the page and the nature of your traffic/user data, it might make more sense to take advantage of caching by making the initial loaded resource (the HTML file) completely static and loading the bootstrapped data in a single separate request.
Yes, absolutely. If the initial HTML page is heavy, and can be cached for all users, then separate makes sense. If the initial HTML page is light, or user-specific (the usual case for a backbone app) then bootstrapping in a single HTTP request makes sense.