/ Published in: PHP
Usually when you're using different CSS files on your site, they might take a quite long to be loaded. Using this PHP code, you can compress them into a single file with no unnecessary white spaces or comments. Why we need to compress multiple CSS files? The answer is: the compressing procedure may take a less time than a total time of loading each file separately.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function compress_css($buffer) { /* remove comments in css file */ /* also remove tabs, spaces, newlines, etc. */ return $buffer; } /* a list of your css files */ include('style.css'); include('css/menu.css'); include('css/typography.css'); include('css/print.css'); include('inc/css/footer.css'); ?>
URL: http://www.apphp.com/index.php?snippet=php-compress-multiple-css-files