Website optimization geeks suggest that we try to minimize file size while serving web pages. Most of the time, web designers use multiple CSS files to make task management more accessible, but this requires as many HTTPS requests as there are CSS files. The following script will allow us to serve all your CSS files as a single HTTPS resource, minified (by removing comments and extraneous white space), and gzip-compressed.
header('Content-type: text/css'); ob_start("compress"); function compress($buffer) { /* remove comments */ $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer); /* remove tabs, spaces, newlines, etc. */ $buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer); return $buffer; } /* your css files */ include('master.css'); include('typography.css'); include('grid.css'); include('print.css'); include('handheld.css'); ob_end_flush();
Was this information helpful? What other tips would you like to read about in the future? Share your comments, feedback, and experiences with us by commenting below!
Total 0 Votes
0
0