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:
- In Drupal 8, all assets must be declared through libraries. Libraries are declared in
<module/theme name>.libraries.ymlfiles. We add a newlicensekey with a map containing the following key-value pairs:name(license name),url(URL to the project's license) andgpl-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 - Third party libraries (i.e. libraries with the
remotekey-value pair) are required to have their license info declared, if not, theLibraryDefinitionMissingLicenseExceptionexception will be thrown. - Libraries without the
licensekey 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. - 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.