Retrieving HTML templates asynchronously

The final step to mastering client-side templating is a development practice that allows us to load templates dynamically and use them in a web page that has already been loaded. This approach can lead to more scalable implementations than the approach of embedding all the available templates as <script> tags inside the HTML source of each page.

The key element of this technique is to load each template only when it is required for the presentation of a web page, commonly after a user action. The main benefits of this approach are that:

  • The initial page load time is reduced since the HTML of the page is smaller. The gains from the reduction of the page size become even greater if our application has a lot ...

Get jQuery Design Patterns now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.