Combines / Merges your code at run-time, for a great workflow during development
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

CombineJS -- A light-weight, run-time script combiner

!important: CombineJS is only used during development! You can use the combined script in a static way on your production or test environment.

CombineJS aims to help (client-side) javascript developers:

  • avoid having any variable in the global object
  • maintain a clean file structure
  • debug

CombineJS does this by giving developers the ability to:

  • wrap all their code in a self-invoking function
  • spread their code among multiple files, during development
  • receive a correct linenumber & file name from an uncaught exception


Currently, CombineJS only works in Chrome. But, as stated above, CombineJS is only used in a development environment, so this should not be a problem. In your production and testing environment, you can simply use the combined script and import that instead of BuildJS. You won't need dynamic building of the combination script.

Support for Firefox is on it's way!

How it works

When you load a page which imports the script, it starts looking for the Initial script. In this script you can refer to other scripts which you want to combine with it.

To import CombineJS into your page:

<script src="path/to/combine.js" data-combine="path/to/initial/file.js"></script>

Your initial file should refer to the other files like this:


For every reference that is found, BuildJS will simply read the file, and paste it in place of the reference code. It will also keep track of the line numbers, so it can give correct error messages when an error is thrown.

After the combined file is built up, a new, temporary file is created using the HTML5 File API, than a script element gets added to the page with a reference to the temporary file.

Tip: Indenting will be applied to the combined file, meaning; you can indent a reference and the whitespacing before it, will be applied to the imported script.

How to download the combined script?

When you are done developing, you will want to download the combined script and put it on your production server. You can do so by simply typing "getAppCode()" into console. A button will then appear in the right upper corner, which you can use to "Save As" the script.

Plans for automatic compression and exporting are still in the making!


CombineJS is licensed under the terms of the MIT License, see the included LICENSE file.