How to add Libre JS licenses to your javascript files

Although the LibreJS project slipped a bit out of public sight, being clear about the licenses of our frontend Javascript code should be common sense. Here is how to easily report your codes license to users.

How to add Libre JS licenses to your javascript files

The easiest way to add a license to an external Javascript file is through the use of the @license annotation in a source code comment.

// @license [magnet link] [identifier]

[your code]

// @license-end

A magnet link is a URI scheme that identifies a file by content on a peer-to-peer network via cryptographic hashing. In this case, it specifies a file on the Bittorrent network.

A common license to link would be, e.g. the GPL-3 license, which would look like this.

// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-3.0

[your GPL-3 licensed code]

// @license-end

A list of common licenses is available on the LibreJS documentation website or if you like the most up-to-date list you can take a look at the plugin repository, more specifically the ./common/license-definitions.json.

The LibreJS browser plugin should now pick up on the licenses and allow execution of it.

Discussion