Most client template engines have the same concept. You can download the templates remotely using XHR, but this will add the terrible overhead of the HTTP request.
The best alternative would be to create each of them in your own file, and on the server side of the script, merge into your HTML page.
Finally, the final option is to add them built into your javascript rendering functions - this will work for very small templates.
source
share