title: Minify CSS and JS in CodeIgniter Efficiently
body: <p>So I am working on a project using the PHP framework CodeIgniter (<a href="http://ellislab.com/codeigniter">http://ellislab.com/codeigniter</a>) and inside of it, we are using a lot of various CSS/JS files that are being called in our header include. </p>
  
  <p>I've used the Minify tool before on WordPress sites and other projects, and ran across this library for CodeIgniter on GitHub (<a href="https://github.com/ericbarnes/ci-minify">https://github.com/ericbarnes/ci-minify</a>) and figured I would use it on my project. </p>
  
  <p>It works all fine and dandy, but unfortunately I am compressing so many CSS and JS files that by the time the page loads, it would have been quicker if I <em>hadn't</em> used it. </p>
  
  <p>Here's what the code looks like in my controller: </p>
  
  <pre><code>    // minify css
      $cssfiles = array('assets/css/normalize.css', 'assets/css/hook-new.css', 'assets/css/hook.css', 'assets/css/components.css', 'assets/css/rtl.css', 'assets/css/global.css', 'assets/css/body.css', 'assets/css/mediaqueries.css', 'assets/select2-3.4.3/select2.css', 'assets/jquery_bootstrap/css/custom-theme/jquery-ui-1.9.2.custom.css');
      $cssfile = $this-&gt;minify-&gt;combine_files($cssfiles);
      $csscontents = $this-&gt;minify-&gt;css-&gt;min($cssfile);
      $this-&gt;minify-&gt;save_file($csscontents, 'assets/css/all.css');
  
      // minify js
      $jsfiles = array('assets/js/application/js_config.js', 'assets/js/bootstrap.min.js', 'assets/js/custom.js', 'assets/select2-3.4.3/select2.js', 'assets/js/startup.js', 'assets/ckeditor/ckeditor.js', 'assets/js/jquery.validationEngine-en.js', 'assets/js/jquery.validationEngine.js', 'assets/js/scripts.js', 'assets/js/application/js_timer.js');
      $jsfile = $this-&gt;minify-&gt;combine_files($jsfiles);
      $jscontents = $this-&gt;minify-&gt;js-&gt;min($jsfile);
      $this-&gt;minify-&gt;save_file($jscontents, 'assets/js/all.js');
  </code></pre>
  
  <p>So I'm taking these large arrays of CSS and JS files, compressing them, then saving them to one large file. But is there a better and more efficient way of doing this? </p>
  
  <p>I know I could combine them by hand, but then when I am working on things, I have massive files to sift through. Not only that, but I like Minify's ability to get rid of unnecessary white space and really condense the code. </p>
  
  <p>So any thoughts on how I can efficiently accomplish this? </p>
  
  <p>Thanks!</p>