Is it possible to create a header file of javascript and css scripts?

advertisements

I have no much idea about web programming, I am looking for some way to create header file for javascript and css whether its possible ?

here is scenario, assume I have 100s of javascript and css if I have to create html or php script everytime I have to put these line

<script type="text/javascript" src="../src/jquery.1.js"></script>
<script type="text/javascript" src="../src/jquery.2.js"></script>
...
...
<script type="text/javascript" src="../src/jquery.100.js"></script>

<link rel="stylesheet" type="text/css" href="../jquery.1.css" />
<link rel="stylesheet" type="text/css" href="../jquery.2.css" />
...
...
 <link rel="stylesheet" type="text/css" href="../jquery.100.css" />

I want to create only one file which contains all javascript and css, and their path and then want to include it in html like this, I expect something kind of C

   include 'all_java_css'
   <html>
         <body>
           <p> all included</p>
        </body>
  </html>


First of all, if you can try and put as many of them files into one, that would be better. Instead of calling 100 of each, you could only call a few, making run times faster.

Also, add all this scripts to a .html or .php file for example:

<script type="text/javascript" src="../src/jquery.1.js"></script>
<script type="text/javascript" src="../src/jquery.2.js"></script>

and save it as header.html.

Then in your main file, you can do this:

<html>
    <head>
        <?php include('header.html'); ?>
    </head>
    <body>
        ...
    </body>
</html>

You need to make sure that your main file is 1) a .php extension and 2) can actually run PHP.

Second of all, you need to make sure header.html is in the same directory as index.php or whatever the php file is.

If not, you can always use

<?php include('inc/header/all_java_css.html');?>

If you do not have PHP, you can do this: In the head:

<head>
    <meta name="add">
</head>

Then using jQuery:

$('meta[name="add"').load('all_java_css.html');