JS include

06.Jul.2010

In order to lower down number of http requests and speed up your website, you can use regular JS include, to include PHP file.

<link rel="javascript" type="text/javascript" href="alljs.php">

PHP JS include file

This is how PHP file, that includes all JS files you want to be included, should look on your server:

1
2
3
4
5
6
7
8
9
10
11
//turn on compression if possible
if(extension_loaded('zlib')){ob_start('ob_gzhandler');}
else ob_start();
 
include('jquery-latest.js');
// list of included JS files
include('jquery.fancybox-1.3.1.pack.js');
 
//send JS header
header('Content-type: application/javascript');
ob_end_flush();