问题
I am wondering if there is a way to store <link>
or <script>
reference elements required for multiple web pages(AngularJS, Fonts, JQuery, Scripts, Google Analytics, Etc.) in a file and then import that file into all of my HTML files(e.g. I can change a file in some place and since it is referenced in all of my pages it will update all of those pages).
回答1:
Using HTML Imports would support this use case, but it is currently in the draft phase.
<link rel="import" href="myfile.html">
If you're interested in using this functionality now there are polyfills that support it. Another option that has been mentioned is to use a template system to add the necessary dependencies to the HTML when the page is requested, or even at build time.
来源:https://stackoverflow.com/questions/50221796/list-common-html-reference-tags-in-one-file