Posted By

theworldofdan on 07/21/11


Tagged


Versions (?)

Load multiple CSS files at once


 / Published in: PHP
 

URL: http://www.catswhocode.com/blog/10-life-saving-php-snippets

  1. <?php
  2. // Source: http://www.catswhocode.com/blog/10-life-saving-php-snippets
  3. // Could be modified, I can't remember if I did
  4.  
  5. $offset = 60 * 60 * 24; // Cache for a day
  6. header('Content-type: text/css');
  7. header('Cache-Control: max-age=' . $offset . ', must-revalidate');
  8. header('Expires: ' . gmdate ("D, d M Y H:i:s", time() + $offset) . ' GMT');
  9. ob_start("compress");
  10.  
  11. function compress($buffer)
  12. {
  13. /* remove comments */
  14. $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
  15. /* remove tabs, spaces, newlines, etc. */
  16. $buffer = str_replace(array("
  17. ", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
  18. return $buffer;
  19. }
  20.  
  21. /* your css files */
  22. include('base.css');
  23. include('style.css');
  24. include('typography.css');
  25. include('forms.css');
  26. include('jquery.fancybox-1.3.0.css');
  27.  

Report this snippet  

You need to login to post a comment.