I’m building a backbone.js application, and don’t quite know where to put my templates. Should they be in separate files that I load when I need them via require.js? Should I load them all right away with require.js?
I’m building a backbone.js application, and don’t quite know where to put my templates.
Share
Both.
When a user loads the page from your server, you should immediately send all of the templates that they need to get the basic page layout and application up and running. Then you can decide which templates they are most likely to use next and pre-load those if you want. For the templates that work with pages they are less likely to use, or for pages that they have to go through a series of steps to get to, delay loading those templates until they need to be available.
There’s no hard and fast rules about this, though. You’ll want to experiment with different configurations and options so that you can create the best user experience possible for your application.