Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Concatenate and minify Javascript files.
tree: 853dc78f14

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


Javascript compiler


Reducing the number of javascript files in your project and keeping them as small as possible can have tremendous benefits with regards to page load speed. This module will compile and minify javascript files at runtime and cache the results so you don't have to worry about adding this step to your deploy and deploy testing.

Bonus benefit: You can split your javascript into multiple files for increased maintainability, AND keep your raw scripts out of your docroot.

Requirements & Installation

  1. Download or clone this repository to your Kohana modules directory.
  2. Enable the module in your 'bootstrap.php' file.
  3. Compile scripts directly into a template variable or a view.

Example View



Example Controller


public function action_index() {
    $this->request->response = View::factory('example', array(
        'scripts' => JsCompile::compile(array(
            APPPATH . 'js/jquery-autocomplete-plugin.js',
            APPPATH . 'js/sample.js'

Integration with head.js

If you use head.js or another javascript loader that requires you pass the name of the javascript file instead of creating a link directly into the document, you can simply pass an extra variable to compile(), like so:

    APPPATH . 'js/jquery-autocomplete-plugin.js',
    APPPATH . 'js/sample.js'

Which returns:


Instead of the tag:

<script src="/js/js-cache/db554181f11f9189951cea98f3b4b697-1288017184.js"></script>

Thanks to

  • Zeelot One of my Kohana heroes, and from whom I shamelessly stole this README format.
  • Douglas Crockford My big Javascript hero, and author of the original JsMin.
  • Ryan Grove Author of the PHP conversion of Crockford's JsMin script that I use in the vendor directory.
  • Mon Geslani Author of Kohana LESS compiler module, from which I took the original inspiration.
Something went wrong with that request. Please try again.