Until now, templates have been declared as script tags in the index.html
file. While this is a good approach for small projects, it is not a good idea to put all your templates directly in the HTML file.
With Browserify, you can extract all your template files into individual files, with the advantage of modularization and a cleaner index.html
file. Another benefit of modularizing templates is that you can pre-compile all the templates, saving resources in your users' browsers.
With Browserify, you can modularize almost any template format: jade, Handlebars, Underscore, and so on. It uses a transformation process described in Figure 4.5. If you have worked with other bundler tools such as webpack, transformations are analogous to pre-processors.

Figure 4.5 The transformation process
Templates are in plain text; the text is passed to a function that compiles it into a JavaScript function that Browserify can process as a regular JavaScript file. To apply the necessary transformation...