Posted By

jamesming on 11/27/08


Tagged


Versions (?)

Who likes this?

7 people have marked this snippet as a favorite

danillos
ntamas
bryandease
nkrstevski
vali29
wirenaught
tux-world


Compress multi CSS with PHP


 / Published in: PHP
 

URL: http://reinholdweber.com/?p=37

  1. <?php
  2.  
  3. header('Content-type: text/css');
  4.  
  5. ob_start("compress");
  6.  
  7. function compress($buffer) {
  8.  
  9. /* remove comments */
  10.  
  11. $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
  12.  
  13. /* remove tabs, spaces, newlines, etc. */
  14.  
  15. $buffer = str_replace(array("
  16. ", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
  17.  
  18. return $buffer;
  19.  
  20. }
  21.  
  22.  
  23.  
  24. /* your css files */
  25.  
  26. include('master.css');
  27.  
  28. include('typography.css');
  29.  
  30. include('grid.css');
  31.  
  32. include('print.css');
  33.  
  34. include('handheld.css');
  35.  
  36.  
  37.  
  38.  
  39. ?>

Report this snippet  

You need to login to post a comment.