Open Source Licenses, JS, and Minification

I’m definitely not a lawyer and I detest reading legalese, but I have a strong interest in the legal considerations of the technology I work with. One area I’ve done a lot of research into in the past is the implications of different open source licenses, which led to this older blog post comparing common licenses.

Recently, one of my devs asked how this applied to JS and minification. Here’s the quick response I tossed together:

Let’s assume we are looking at the MIT license or an equivalent. Remember that ANY third party code requires client approval, and any license other than MIT should be run past me as well.

The MIT license specifically requires that the license is included somewhere in the software, but it does not need to be public facing. Typically, the license is included as a comment at the top of the source files. However, minification strips out the comments and combines source code into a single file. This raises three possible scenarios:


  1. All of the code in the file is under MIT license. In this case, you can inject the copyright statements for each of the libraries followed by the main body of the MIT license above the minified code. We do this automatically for the CreateJS libraries as part of our build process.
  2. Client code & MIT licensed code. I would recommend that all open source code is treated as in #1, and client code is minified into its own file (potentially with a copyright header specified by the client). This is much cleaner than trying to mix them.
  3. Code with different licenses. This gets much more complex, and should be dealt with on a case by case basis.

I’d be interested to hear about how other companies are dealing with this topic, or related ones.

Grant Skinner

The "g" in gskinner. Also the "skinner".

@gskinner

4 Comments

  1. When I worked for [large internet portal], we kept the copyright header at the top of each minified library. When concatenated, the copyright headers separated each section of code, all in one file. I don’t remember the details of concatenating proprietary code, but I don’t think we separated it into a different file. With a header before the proprietary section, it seems clear enough which parts of code were not open source.

  2. If you add an exclamation point after your comment block opener, then minifiers honor it and will not remove it.

    /*! your license
    * information here
    */

  3. @Steven
    This doesn’t seem to be the case with Google Closure. What tools have you had success with – that would be a nice trick.

  4. Interesting. With my tests, it works with Uglifier and YUI. Haven’t tried it with Closure Compiler, yet. At the end of the day, you can still remove the ! from any library you’re using prior to minification.

Leave a Reply

Your email address will not be published. Required fields are marked *