0
I am creating a website where on all pages the script and link tags to import the JS and CSS libraries are repeated.
Is there any way for, for example, I create a script.html file (for example) and import this file to all my pages consequently?
Because when adding a new library I need to go page by page and carry out the manual inclusion and thus I would include in only one file and this would go to all others automatically.
I tried by Jquery through the functions load()
and html()
but I couldn’t, someone has some solution regarding?
Below is an example:
<!-- Última versão CSS do BootsStrap compilada e minificada -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<!-- Metis Menu -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/metisMenu/2.7.0/metisMenu.min.css" />
<!-- Template SB Admin 2 -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/startbootstrap-sb-admin-2/3.3.7+1/css/sb-admin-2.min.css" />
<!-- ícones do Template -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<!-- Data Tables -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css" />
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.15/css/dataTables.bootstrap.min.css" />
<link rel="stylesheet" href="https://cdn.datatables.net/responsive/2.1.1/css/responsive.dataTables.min.css" />
You don’t use any technology server-side? This is usually done on the server side.
– Jéf Bueno
Have you considered the idea of grouping all the scripts in just one file and minify it? There are tools that do this for you and in the end you only need to import one file. The same can be done with CSS.
– Woss
In the case the import, for example, are from several libraries hosted in Cdn, follows below. It’s worth minifying all libraries in one file?
– Mateus Mattielo Nickhorn
Edit the question and add the code directly to it if it is relevant to the problem. Just paste the code into the editor, select it and press the shortcut
Ctrl+K
to format it properly.– Woss