Change record status: 
Project: 
Introduced in branch: 
8.x
Introduced in version: 
Description: 

We want Drupal 8 to be fast by default. One aspect of being fast by default is the front-end performance, and one aspect of that is the amount of data we send to the browser. JavaScript aggregation and minification can be a huge help in that regard, but has long been impossible, for multiple reasons. One of those reasons is that minifying aggregated JS assets that have different licenses would in many cases break the involved licenses.

To solve this problem in a pragmatic, realistic way, the Free Software Foundation proposed JavaScript License Web Labels (JSLWL). With that implemented, Drupal 8 will finally be able to aggregate and minify JS without violating licenses.

But to implement JSLWL, we of course need to reliably know the licenses of all the JS files in Drupal core and contrib. Sadly, many JS files don't specify their license, and if they do, they specify it in wildly different ways.

Therefore:

  1. In Drupal 8, all assets must be declared through libraries. Libraries are declared in <module/theme name>.libraries.yml files. We add a new license key with a map containing the following key-value pairs: name (license name), url (URL to the project's license) and gpl-compatible (whether this license is GPL-compatible or not). e.g.:
    backbone:
      remote: https://github.com/jashkenas/backbone
      version: 1.1.0
      license:
        name: MIT
        remote: https://github.com/jashkenas/backbone/blob/1.1.0/LICENSE
        gpl-compatible: true
      js:
        assets/vendor/backbone/backbone.js: { weight: -19 }
      dependencies:
        - core/underscore
    
  2. Third party libraries (i.e. libraries with the remote key-value pair) are required to have their license info declared, if not, the LibraryDefinitionMissingLicenseException exception will be thrown.
  3. Libraries without the license key are assumed to be "GPL2+", like Drupal, and are hence GPL-compatible. This means that none of the modules on drupal.org that include JavaScript code need to define licenses, unless they reference externally hosted JavaScript, which is a tiny minority.
  4. This will allow us to generate a "JavaScript License Information" page, as required by http://www.gnu.org/licenses/javascript-labels.html. We will implement that in #2258313: Add license information to aggregated assets.
Impacts: 
Module developers
Themers