Answer by A Quora admin:
Approach 1 (Recommendation for Static pages): Write all your scripts that need to be reused in a separate file with the extension .js; Similarly if you want the styles to be used across the pages write it in a separate .css file.
Now all you need to do is add a script tag referencing the location of the script.
Approach 2 (Recommendation for dynamic pages) : you can either use single page application (SPA) in which whenever your menu item is clicked an AJAX call will be made to do data binding in a div/ generating the dynamic HTML,
Sharing with you an example from my jsfiddle:
There is one more approach, usually while developing web application with the help of server side scripting like etc, In which we use Master pages concept that preserves the templates and the general scripts as they are referred only in the master pages and all the child pages reuses them. In this case also, we need to add the references only in the master page.
Hope it helps, let me know if you need further assistance.