A journey into freedom

I discuss what I’ve discovered about non-free JavaScript and LibreJS.

So, let’s cover the base ground I guess. What is non-free JavaScript? This is the part where most (basically every single blog post/website I’ve seen) sites would include a link to Richard Stallman’s report titled “The JavaScript Trap”. Since I don’t really like reading and don’t necessarily want to follow in the footsteps of “traditional blogs”, I’ll sum it up really quick:

The community of “free software” doesn’t really approve of the concept of running non-free programs (programs which have restrictions on modifications and redistributions of the program) and the majority of the JavaScript code that is run on your browser is non-free. Most of the time, non-free programs “mistreats” its users (e.g. snooping, recording sensitive data, tracking you etc.), therefore non-free JavaScript should basically not be used. The alternative, is to use, say, a browser or a plugin that only allows free JavaScript to be run (JavaScript that you’re free to modify, and is also not obfuscated in any way). LibreJS detects non-free and obfuscated JavaScript and blocks it.

Using LibreJS

Despite the fact that I’m a very confident Google Chrome user and it is always the browser of choice that I fall back to time and time again, in order to use LibreJS I need to use either GNU IceCat (Think Firefox, but not fire and not a fox), or “any Mozilla browser” (according to the LibreJS webpage). Therefore, Firefox is the browser of choice on Windows, considering that GNU IceCat for Windows is no longer supported.

After installing Firefox and the LibreJS extension for Firefox, I am ready to see what this thing does. Naturally, I decide to test this on my main website and LibreJS flags up the various non-free JavaScript code on the website and blocks it. After digging around, I find the various culprits: EasyTabs, which is a jQuery plugin that lets you easily add navigation tabs to a webpage, Hashchange which is used by EasyTabs, and various other JavaScript code snippets that I wrote to interact with EasyTabs and patch various… poorly implemented features. I take a look at the various licenses for the two jQuery plugins and discover that they’re dual licensed by the GPL3 and MIT licenses (I never knew that something could be covered by more than one license, but the more you know I guess!). While I am at it, I come up with the various licenses for the code I wrote and look at ways to tell LibreJS what licenses are applied to what JavaScript code.

Cooperating with LibreJS

Surprisingly, informing LibreJS that your JavaScript is free is quite straightforward and simple. There are two methods:

  • Putting some fancy comments in your JavaScript code that tells LibreJS what license it is covered by. It’s incredibly simple: Add a @license comment at the beginning of your code with the magnet link to the license and its license identifier, which is found under the list of free licenses, then add a @license-end comment to the end of your code. It’s really that simple.

    // @license [magnet link to license] [license identifier]
     * All of your JavaScript code goes here, as normal
    // @license-end
  • Making a fancy table that tells LibreJS what file is covered by what license (my personal table looks like this - it doesn’t have to look terrible for LibreJS to know about it!). And it too is incredibly easy - just make a regular HTML table with the id jslicense-labels1, with three columns consisting of:

    • The link to your JavaScript file (normally this would be the same link as in an HTML <script> tag)
    • The URL link to the license (from the list of free licenses)
    • The source code of the JavaScript file. This would normally be the non-minified version of your JavaScript file for example.

Since the procedure to “freeing your JavaScript” is so simple, I went ahead and stated the various licenses of the JavaScript code that my site uses since they were in fact free already, and LibreJS just needed to be told that they were.

Removing non-free JavaScript

So, telling LibreJS about where the free JavaScript is located is fine, but if a website were to use non-free JavaScript, how do you get that to cooperate with LibreJS? There’s basically two methods and they’re both really simple:

  1. You remove non-free JavaScript. As simple as that. If you have no non-free JavaScript, then LibreJS cannot complain about non-free JavaScript.

  2. You do absolutely nothing. Since it should be up to the consumer of whether they should run non-free JavaScript, you let them choose. LibreJS allows the user to decide whether they want to run certain snippets of JavaScript which are determined to be non-free.

Given the two options, I decide to choose the latter for the sake of this blog, which runs the Disqus commenting system and Google Analytics to get an insight of the number of readers of my blog. I personally have no problem with people choosing to opt out of Google Analytics (by using LibreJS, for example) as well as the comment system (which, as of the time of writing, is rarely used).

Thoughts about LibreJS

So, despite the very controversial views on LibreJS (mostly negative), I personally think that LibreJS is a good step in the right direction for filtering out non-free JavaScript. It is a big eye-opener for those that take non-free JavaScript for granted, and considering that basically nothing works (YouTube, signing into my university account, slack/skype/whatsapp for web…) it heavily restricts what you can actually use on the internet.

Nonetheless, it could still be improved in my opinion. For example, there are many JavaScript files out there that are free and some that even include their licenses in comments at the top of the file, yet LibreJS doesn’t detect these unless they have the @license tag. If say, LibreJS had some sort of way to scan a file for a license, that would make it a lot more forgiving.

Overall, it’s not very useful for today’s modern web where almost every website uses non-free JavaScript. Sure, I could enable LibreJS but I feel that I’d spend more time allowing non-free JavaScript through LibreJS than I would just ignoring the fact that I’m running non-free JavaScript.

Written on September 22, 2019