I have multiple scripts like <script> ..... </script> <script> ..... </script> <script> ..... </script> I want to move them all in a .js file can anyone help ?
If you have multiple .js files like this: <script> This is the content of the 1st file </script> <script> This is the content of the 2nd file </script> <script> This is the content of the 3rd file </script> HTML: Just put all the contents into one .js file like this: <script> This is the content of the 1st file This is the content of the 2nd file This is the content of the 3rd file </script> HTML:
LOL why not create a simple PHP script that will merge all script to one? http://www.ejeliot.com/blog/72 http://www.electrictoolbox.com/combine-minify-javascript-php/
Do note that if you have a heavily traffic site that this is a potential bottleneck. You are requiring your webserver to spin up an instance of PHP and perform multiple disk reads to generate a single output file. You should use something like this to generate a single file that you still add in to the HTML for a normal script include - if you are concerned about the overhead that is - and this overhead is minimal if you are dealing with low traffic.