Next: , Previous: Free Licenses Detection, Up: Top

7 Setting Your JavaScript Free

Do you own or maintain a website? If so, you can take a stand for user freedom. All you need to do is to release your JavaScript code under a free license that will be easily identified by users while visiting your pages. If you are already using a free library or made a JavaScript app from scratch, it might only take a few minutes!

All JavaScript code on a page (inline, on-page, and external) shares a common scope, and thus is generally either rejected or accepted as a whole by LibreJS. If some JavaScript code is found to be nontrivial and nonfree, then most of the time, all the the rest is discarded as well.

On your website, by taking a look at your HTML source, you can identify distinct pieces of JavaScript that might be free and some other that are nonfree.

Tip: By running LibreJS on your page, you will get a list of all the JavaScript that was blocked while loading. This can help give you an overview of the JavaScript in your page.

7.1 Adding a stylized comment in your JavaScript files and on your page

Once you have identified all JavaScript and replaced or removed the nonfree ones, you can start adding explicit license notices in your JavaScript files and on your pages. Starting from the external files is probably easier. You can use long license notices.

See a “Convention for releasing free JavaScript programs” in the JavaScript Trap

Adding this notice will ensure LibreJS will find the JavaScript file to be free. The @licstart and @licend lines at the beginning and end of the stylized comment are necessary to make a clear statement that the _entire code_ in the file is free. This means that you must ensure no nonfree code was carelessly appended at the end of the file.

For the main HTML page, what the license notice will cover is the JavaScript contained in all <script> with on-page code and the inline

JavaScript (in event attributes such as onload, onclick, etc, ...). Since external files have their own stylized comment, they are not covered by the notice in the main HTML page. Make sure to identify all the licenses available. LibreJS will only ensure it matches a notice of an allowed license once, so the order does not matter, but the responsibility is on you to make sure all code is under the free licenses mentioned between @licstart and @licend.

You should make only one @licstart @licend comment in your page, since it pertains to the entire code on page across all <script> tags and inline html attributes.

7.2 JavaScript Web Labels

You can also choose to publish license information about your external JavaScript files using the JavaScript Web Labels method. Extensive information on JavaScript Web Label is detailed at the following URL:

The JavaScript Web Labels allow you to easily provide –in the same time– information for LibreJS and for your users. All it requires is to create a page listing JavaScript files and the canonical urls of their free licenses.