40

I guess this is actually a legal question, but it relates to software. I'm about to include a JS plugin in a project. The comments include:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  1. Is using this in my web site "redistribution?"
  2. If I minify this to conserve bandwidth, I assume it will strip all comments. If the answer to #1 is yes, doesn't that imply I'm legally not allowed to minify it?

(That would stink, since I was planning to auto-minify all JS as part of the deploy process.)

2
  • Is this going to be server-side or client-side? Client-side is distribution, server-side isn't (as a general rule). Feb 7, 2011 at 19:09
  • 3
    @DavidThornley - I agree with your point but I can't think of a good reason why you'd minify server-side JS anyway. Jan 11, 2012 at 17:36

4 Answers 4

38

Most minifying software has some method of leaving a comment in-situ for this exact purpose.

For example, from the YUI Compressor documentation:

  + C-style comments starting with /*! are preserved. This is useful with
    comments containing copyright/license information. For example:

    /*!
     * TERMS OF USE - EASING EQUATIONS
     * Open source under the BSD License.
     * Copyright 2001 Robert Penner All rights reserved.
     */

    becomes:

    /*
     * TERMS OF USE - EASING EQUATIONS
     * Open source under the BSD License.
     * Copyright 2001 Robert Penner All rights reserved.
     */

Google Closure Compiler will preserve any JavaDoc block that has either the @license or the @preserve tag in it:

With @license:

    /* 
     * TERMS OF USE - EASING EQUATIONS
     * @license Open source under the BSD License.
     * Copyright 2001 Robert Penner All rights reserved.
     */

    becomes:

    /* 
      TERMS OF USE - EASING EQUATIONS
      Open source under the BSD License.
      Copyright 2001 Robert Penner All rights reserved.
     */

With @preserve:

    /* @preserve
     * TERMS OF USE - EASING EQUATIONS
     * Open source under the BSD License.
     * Copyright 2001 Robert Penner All rights reserved.
     */

    becomes:

    /* 
      TERMS OF USE - EASING EQUATIONS
      Open source under the BSD License.
      Copyright 2001 Robert Penner All rights reserved.
     */
2
  • Oh cool, nice to know! Feb 24, 2011 at 20:17
  • @Nathan Long: This is the recommended approach by the people who make the minimizers.
    – Orbling
    Feb 24, 2011 at 20:18
23

Yes

With a caveat. You would have to put the notice elsewhere on the site. Typically under a Terms & Conditions or Notices page. You could do this simply by appending the following to the top of every JS piece you have minified (or simply on top of the single JS file):

/** Notice 
  *
  * This file contains works from many authors under various (but compatible)
  * licenses. Please visit http://example.com/notices for more information.
  *
 **/
4

Actually, why not preserving the notice as part of the minification step itself ?

The simplest way would be to first extract the notice (manually) and save it somewhere. Then your minification script can just minify the JS and then concatenate the unaltered notice.

I expect it to be small enough of course... if it's big, then Josh K's answer is probably better.

3
  • The issue becomes automatically detecting the notice when building. Another point you touched on is that the notices can be quite large and costly to redownload.
    – Josh K
    Feb 7, 2011 at 21:30
  • @Josh K: I did say manually extracting the notice. As for large notices, I think I got that covered too, in which case I agree it's better to have it separated. Feb 8, 2011 at 7:16
  • Specifically, I was thinking of the jQuery Easing Plugin. if you look at the source, there are almost half as many lines of terms and conditions as of code: gsgd.co.uk/sandbox/jquery/easing/jquery.easing.1.3.js So in this case, if I can't remove the notice, that's a big problem for minification. Feb 24, 2011 at 20:15
4

From my reading of the licenses, I believe that in order to be totally safe you need to include the complete license text with any distribution of the software or its derivative works (including minified JS). From the major open-source licenses:

GPLv3:

You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you ... give all recipients a copy of this License along with the Program. ...

You may convey a work based on the Program ... in the form of source code under the terms of [the above section].

MIT license:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

BSD licenses:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

It looks like this approach is not being taken by most people, however. Even the official minified Bootstrap from Twitter only contains a small copyright notice, so you'd be in violation of the MIT license if you served it to your users.

Not the answer you're looking for? Browse other questions tagged or ask your own question.