Hi guys,
Can anyone please recommend the best and easiest way to include multiple Javascript files on a (PHP based) web page?
I have a website that uses jQuery, and anything up to around 10 plugins on any one particular page. I'm not entirely sure of the best way to go about including all these files to make life simple for me as a dev, and to ensure that they are best served to a user.
Ideally I thought the easiest way myself would be to build a PHP handler file that I could use to call which plugins I reqire for each page, and then have it output javascript that used document.write() to 'include' each plugin JS file on the page, like so:
<script src="handler.php?jquery,plugin1,plugin2,plugin3,plugin4"></script>
which might then output Javascript with multiple document.write()'s to each individual plugin.
I am led to believe this might lead to problems with browser caching however, as some browsers ignore caching of items with query strings.
Is this OK to do, or is there a simpler method that I'm perhaps missing?