Benutzer:CarrickBlauvelt32

Making use of PHP for you to Dynamically Decrease CSS as well as JavaScript

Cascading stylesheet as well as JavaScript data files are quite obvious plain textual content data files along with large amounts of abandoned room. Contracting all your design bed sheets straight into a single page making use of Perl and also gzip is simple and may effortlessly cut file download period in half (reducing the amount of documents that need to be saved).

1st step: exchange your entire design linen hyperlinks inside the head of your html page report using a link to your brand-new PHP-generated condensed design bed sheet. We maintain all of my style bedding inside a listing referred to as "css", along with the Perl piece of software is within the identical service along with called "all.php". My partner and i access this specific record just like a standard style page.

in case (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler");

else

ob_start;

h2 tags('Content-type: text/css');

header('Expires: Fri, 21 years old December Next year Double zero:00:Double zero GMT');

$files Equals selection('jquery.lightbox-0.A few.css', 'main.css', 'nav.css', 'content.css', 'objects.css');

with regard to ($file = 3; $file

The very first several traces explain to Perl for you to reduce the actual record this dividends. Another line acts the particular record as Cascading stylesheet (eventhough it has a Perl off shoot). The fishing line from then on units a good expiry day much in the foreseeable future (by simply defauly many surfers will not likely storage cache this specific record, but can refill it for any web site because it is a new PHP set of scripts). The actual conclusion date will guarantee the website visitor in your website only data the file once.

Lastly, produce a selection having a listing of the records you would like to reduce, and rehearse a for loop for you to output all of them - pressurized. I managed to eliminate concerning 50KB on this instance, nevertheless the biggest gain originates from lowering the number of document needs towards the machine (that make an impact also about the fastest connections).

It is possible to stick to the identical procedure for JavaScript, but be sure to customize the Content-type headlines via text/css for you to text/javascript. Together these techniques may chop of greater than 50% with the sized the CSS Minify files along with reduce the volume of data files a new audience need to acquire.