41

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.)

Nathan Long
  • 3,657

4 Answers4

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.
     */
Orbling
  • 5,686
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.
  *
 **/
Josh K
  • 23,029
  • 10
  • 67
  • 100
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.

Rag
  • 170
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.

Matthieu M.
  • 15,214