11.25.20

Gemini version available ♊︎

Making JavaScript Suck Less

Posted in Free/Libre Software, Standard at 2:20 am by Guest Editorial Team

By figosdev

JavaScript source

Summary: “Other than that, the first rule of JavaScript is: Do not use JavaScript. But this article is for people who break the first rule.”

First, a disclaimer: this article is not aimed at people making HTML5 games. Milo (Drummyfish) just put out a CC0-licensed game called Anarch, he already likes the suckless philosophy, he made his game work on the browser. Everything he codes is done with care, talent and a serious philosophy. So if you’re making HTML5 games, you can be certain this article is not about you.

“This article is about those sorts of considerations, as well as times when JavaScript isn’t always bad.”Second, for amateurs who are just trying things out, I don’t have a problem with your code not being optimised. Keep it simple if you can, do consider people with older machines (try your code on much older machines, if possible) and don’t worry about the rest.

And if your JavaScript creates an animated splash screen for anything OTHER than a game? Stop, you’re making the Web fucking awful.

Other than that, the first rule of JavaScript is: Do not use JavaScript. But this article is for people who break the first rule.

Fomenteu la lecturaThat’s why there is a second rule: Avoid using JavaScript (JS).

I’m sure there are people who think that as long as JS is under a free license, there’s no problem with it at all. If JS is under a free license, why even complain? You can change it and share the different version, right?

Not that I go around downloading every program with a free license and running it on my computer, because malware with a free license is still malware. Regardless of the license, I want to control what runs on my computer. Remember when that was the real idea of Free Software?

So JavaScript is off by default. If your website doesn’t already work with JS turned off, the clock is ticking before I give up. I might decide it’s worth turning it on. I DO like the idea of only running free JS, incidentally; that should remain a goal. But I don’t want it to run by default, just because it’s free. A lot of the free-as-in-freedom JS out there is crap I don’t want running, don’t want creating problems, don’t want wasting CPU and other resources.

Too many websites use it without a good enough reason, and wherever you draw the line, more consideration needs to go into when people use JS for their websites. This article is about those sorts of considerations, as well as times when JavaScript isn’t always bad.

“I especially hate it when everything loads except the buttons that go to the next and previous page. Many websites don’t do that, and many do.”One question to ask yourself is: did you have enough reason to use JS at all? In other words, did your design really benefit much from the things only JS can do in your particular situation? Techrights is a great example; there is absolutely nothing that Techrights does with JS that I consider useful.

All the functionality (save what WordPress may need, and they used to be more reasonable) that Techrights really needs can be accomplished without JavaScript. The carousel at the front is annoying and unneeded — I avoid the front page for that and other reasons. Is it easy enough to avoid? Absolutely. Is it a worthwhile use of JS? It’s not like we are all going to agree on everything, I get that; but I think this is a perfect example of a superfluous application that can simply be removed.

I really did write this article to talk about JavaScript, not to pick on Techrights, but while we are on the subject Techrights also delivers jQuery to my web browser. Unless it’s WordPress that needs that now (a terrible thought, but it wouldn’t surprise me at these days) I think Techrights could do just fine without installing any extra JS libraries, particularly ones from GitHub.

I don’t expect them to overhaul their entire CMS — when Techrights chose WordPress about 15 years ago, it was not nearly as much of a mess as it is now. Every version that comes out, WordPress has gotten worse in this regard. But this article is not about overhauling both sides of a website; it is about making simpler changes and simpler choices to begin with.

I get that there are applications that are dynamic and communicate with a server without refreshing. These are my least favourite designs, but there is a place for them. This sort of thing is overdone, but some people are going to make flashy bloated bullshit no matter what. Nobody who insists on that is going to care about the points made here; people who like suckless software might avoid JS altogether, but I think we would benefit substantially from more minimalism — with or without JS.

“If you can make your website work without JavaScript, you should strongly consider doing so.”So if I were in charge, I would remove jQuery (if possible) and just leave WordPress, ditch the carousel even if I have to change a template to get it to work without it. Short of WordPress, I would be trying to remove jQuery along with any JS libraries that could be removed.

If you can make your website work without JavaScript, you should strongly consider doing so. I especially hate it when everything loads except the buttons that go to the next and previous page. Many websites don’t do that, and many do.

Using a bloated, complex framework that loads blank pages is another extreme annoyance. I already boycott as many websites that do this as possible. Yes, I still load some of them. What would be better, is if people stopped doing this.

I’ve even made designs that don’t layout properly until JS is enabled — but the page still loads, it isn’t blank. You don’t need to turn JS on just to read what it says, and you really shouldn’t have to. Sure, perhaps you can come up with a good exception. But the problem is that there are too many exceptions, the problem is that people creating websites just don’t care about this.

Just to recap before this article changes its angle altogether:

1. Avoid JS.

2. If you don’t manage that, at least keep it minimal.

3. Avoid extra libraries.

4. Make it so that when JS is off, visitors still get something worthwhile — other than a message to turn JS on.

5. Avoid GitHub — yes, it has most of the JS libraries; all the more reason.

Additionally, if you can make it so that it’s easy (read: “trivial”) to download your JS and run it without an Internet connection, do that. Obviously this doesn’t apply to designs that sync periodically with the web server.

“The key is to keep it simple and minimalist, while still being dynamic.”Here’s an example — you might hate this, but at least it illustrates some of the ideas presented here:

If you have very limited bandwidth, and want to conserve bandwidth for yourself, for visitors or both — you can make a simple “wiki” in JavaScript so that instead of writing full HTML, you can write text like this:

Here is text.
Here is *bold* text, followed by a blank line:

Here is a link: [url]http://techrights.org[/url]

For three lines of text, you’re not saving any bandwidth (or trouble) by not doing something like this instead:


Here is text.<br>
Here is *bold* text, followed by a blank line:<br>
<br>
Here is a link: <a href="http://techrights.org">http://techrights.org</a>

But for an entire website, doing this with a small, single (vanilla) JavaScript file will save you a lot of bandwidth and make your source much easier to edit, read as source, and — this is why I did it — easier to parse from the command line without a browser.

If your website is about coding, this can make it much easier to display snippets of code and handle those properly. It is easier to download a single file with code in it, trim the file, and have a usable copy of the code (code other than JavaScript) already.

“JavaScript is still overrated, still overused.”If someone loads the page in a browser with JS turned off they will still get the text, but it may all run together. If you don’t like HTML, a script like this can make HTML optional, or even let you create your own friendlier alternative (like markdown or bbcode). If you have the ability to use PHP or Python or something else on the server, and this isn’t too intensive for the server load you can afford, you can do this in PHP or Python. But if you can’t afford to run your code on the server side, small amounts of free JavaScript code can do this.

It can also replace HTML with something that can be parsed and then displayed as formatted text without a browser altogether. For example if the wiki script is very simple, or fairly simple and very popular, you can also have a version of it Python, SML, Raku, or Lua. Then people who download your webpage can pipe it directly through their copy of the offline script, which then makes it do the same things from the command line that it would do from JS — without some bloated solution like Node.js from GitHub.

The key is to keep it simple and minimalist, while still being dynamic.

Here is another application that I think sucks less: Suppose you want to either teach coding, or create a simple e-book. You might not even have a smartphone because they’re evil, but you know your friend has a tablet or an e-reader, maybe they even made their own tablet with a Raspberry Pi. At any rate, they either may not have or don’t know how to install an EPUB reader, or they can only do PDF on a fairly small screen — I have worked on all sorts of ways to do e-books (plain text, HTML, EPUB, PDF) but you want them to be able to download a single file they can read even when they don’t have a data connection.

You can do plaintext or everything in a single HTML file, but most people don’t want to scroll through a page that long on their phone or tablet. EPUB is a very nice option because you can zoom large without horizontally scrolling/panning on every single line, but maybe they don’t like their EPUB reader, or find it complicated, or it only reads files from a directory that is difficult for them to get the file to.

“I would love a more minimalist alternative to the Web, maybe with a more minimalist JavaScript alternative as well.”Some PDF readers can wrap text lines, most don’t and fewer (if any) free-as-in-freedom PDF readers do — that’s only useful if they can actually install it on their platform –

In my opinion the most reliable way to do an e-book (not the best for every purpose, I know) is to make a VERY simple HTML file with JavaScript included in the same (HTML) file, as opposed to having it download separately.

Then your simple (and free) JS can keep pages small, make it so they can go to the next page, previous page, skip to the next chapter or go to a specific page number; all of this can be done with very little code (even relative to a single chapter, up to a full-length book) and it will run on anything with a browser — whether downloaded for offline use or simply viewed online.

For smaller, simple applications, this approach also works.

Obviously, it is better for most things to write actual software. JavaScript is still overrated, still overused.

But it is also extremely easy (even without a library) to create an HTML file with a few buttons, add some code to the same file, and have a working program. For a simple application that works online or offline, or for what is absolutely the most beginner-friendly way to create a “gui” application without a lot of skill, familiarity or tedious hacking with library code, vanilla JS makes creating a simple “app” (it will even run on a phone) trivial.

“For the moment, the easiest way to have a subset of Javascript is to simply use less of it.”For programs that save or load data, access the system or do a lot of serious work, you’re still better off writing something with better tools than what’s described here. One of the things I promote is everyone learning how to code — and I do prefer Python or other things based on Python to JavaScript, but for some purposes JavaScript can be useful.

I believe in subsets as well as minimalism. I would love a more minimalist alternative to the Web, maybe with a more minimalist JavaScript alternative as well.

For the moment, the easiest way to have a subset of Javascript is to simply use less of it. This article focused on examples and recommendations around more modest uses, times in which it is better to avoid JS altogether, and perhaps will inspire someone to create a subset of JavaScript that we can use instead.

“I don’t claim that this defines “Suckless” JavaScript; only that it is possible to make JavaScript suck less.”I know that “pulling back” like this on technology doesn’t always work, but we still often end up with rewards when we try.

I don’t claim that this defines “Suckless” JavaScript; only that it is possible to make JavaScript suck less.

Long live rms, and Happy Hacking.

Licence: Creative Commons CC0 1.0 (public domain)

Share in other sites/networks: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Reddit
  • email

Decor ᶃ Gemini Space

Below is a Web proxy. We recommend getting a Gemini client/browser.

Black/white/grey bullet button This post is also available in Gemini over at this address (requires a Gemini client/browser to open).

Decor ✐ Cross-references

Black/white/grey bullet button Pages that cross-reference this one, if any exist, are listed below or will be listed below over time.

Decor ▢ Respond and Discuss

Black/white/grey bullet button If you liked this post, consider subscribing to the RSS feed or join us now at the IRC channels.

DecorWhat Else is New


  1. Links 2/12/2021: OpenSUSE Leap 15.4 Alpha, Qt Creator 6

    Links for the day



  2. The EPO's “Gender Awareness Report”

    There’s a new document with remarks by the EPO’s staff representatives and it concerns opportunities for women at the EPO — a longstanding issue



  3. IRC Proceedings: Wednesday, December 01, 2021

    IRC logs for Wednesday, December 01, 2021



  4. EPO Staff Committee Compares the Tactics of António Campinos to Benoît Battistelli's

    The Central Staff Committee (CSC) of the EPO talks about EPO President António Campinos, arguing that “he seems to subscribe to the Manichean view, introduced by Mr Battistelli…”



  5. Prof. Thomas Jaeger in GRUR: Unified Patent Court (UPC) “Incompatible With EU Law“

    The truth remains unquestionable and the law remains unchanged; Team UPC is living in another universe, unable to accept that what it is scheming will inevitably face high-level legal challenges (shall that become necessary) and it will lose because the facts are all still the same



  6. Links 1/12/2021: LibrePlanet CFS Extended to December 15th and DB Comparer for PostgreSQL Reaches 5.0

    Links for the day



  7. EPO Cannot and Will Not Self-Regulate

    The term financialisation helps describe some of the activities of the EPO in recent years; see Wikipedia on financialisation below



  8. [Meme] Germany's Licence to Break the Law

    Remember that the young Campinos asked dad for his immunity after he had gotten drunk and crashed the car; maybe the EPO should stop giving diplomatic immunity to people, seeing what criminals (e.g. Benoît Battistelli) this attracts; the German government is destroying its image (and the EU’s) by fostering such corruption, wrongly believing that it’s worth it because of Eurozone domination for patents/litigation



  9. EPO Dislikes Science and Scientists

    The EPO's management has become like a corrupt political party with blind faith in money and monopolies (or monopoly money); it has lost sight of its original goals and at this moment it serves to exacerbate an awful pandemic, as the video above explains



  10. Links 1/12/2021: LibreOffice 7.3 Beta, Krita 5.0, Julia 1.7

    Links for the day



  11. Links 1/12/2021: NixOS 21.11 Released

    Links for the day



  12. IRC Proceedings: Tuesday, November 30, 2021

    IRC logs for Tuesday, November 30, 2021



  13. Links 1/12/2021: Tux Paint 0.9.27 and WordPress 5.9 Beta

    Links for the day



  14. [Meme] EPO Administrative Council Believing EPO-Bribed 'Media' (IAM Still Shilling and Lying for Cash)

    IAM continues to do what brings money from EPO management and Team UPC, never mind if it is being disputed by the patent examiners themselves



  15. The EPO's Mythical “Gap” Has Been Found and It's Bonuses for People Who Use Pure Fiction to Steal From Patent Examiners

    The phony president who has the audacity to claim there's a budget gap is issuing millions of euros for his enablers to enjoy; weeks ahead of the next meeting of national delegates the Central Staff Committee (CSC) tells them: "Events show that the delegations’ concerns about functional allowances have materialised. The lack of transparency and inflation of the budget envelope gives rise to the suspicion that high management is pursuing a policy of self-service at the expense of EPO staff, which is difficult to reconcile with the Office’s claimed cost-saving policy, and to the detriment of the whole Organisation."



  16. Video: Making the Internet a Better Place for People, Not Megacorporations

    Following that earlier list of suggested improvements for a freedom-respecting Internet, here's a video and outline



  17. Links 30/11/2021: KDE Plasma 5.23.4, 4MLinux 38.0, Long GitHub Downtime, and Microsoft's CEO Selling Away Shares

    Links for the day



  18. A Concise Manifesto For Freedom-Respecting Internet

    An informal list of considerations to make when reshaping the Internet to better serve people, not a few corporations that are mostly military contractors subsidised by the American taxpayers



  19. Freenode.net Becomes a 'Reddit Clone' and Freenode IRC is Back to Old Configurations After Flushing Down Decades' Worth of User/Channel Data and Locking/Shutting Out Longtime Users

    Freenode is having another go; after “chits” and “jobs” (among many other ideas) have clearly failed, and following the change of daemon (resulting in massive loss of data and even security issues associated with impersonation) as well as pointless rebrand as “Joseon”, the domain Freenode.net becomes something completely different and the IRC network reopens to all



  20. Jack Dorsey's Decision is a Wake-up Call: Social Control Media is Just a Toxic Bubble

    The state of the World Wide Web (reliability, preservation, accessibility, compatibility etc.) was worsened a lot more than a decade ago; with social control media that’s nowadays just a pile of JavaScript programs we’re basically seeing the Web gradually turning into another Adobe Flash (but this time they tell us it’s a “standard”), exacerbating an already-oversized ‘bubble economy’ where companies operate at a loss while claiming to be worth hundreds of billions (USD) and generally serve imperialistic objectives by means of manipulation like surveillance, selective curation, and censorship



  21. IRC Proceedings: Monday, November 29, 2021

    IRC logs for Monday, November 29, 2021



  22. Links 29/11/2021: NuTyX 21.10.5 and CrossOver 21.1.0

    Links for the day



  23. This Apt Has Super Dumbass Powers. Linus Sebastian and Pop_OS!

    Guest post by Ryan, reprinted with permission



  24. [Meme] Trying to Appease Provocateurs and Borderline Trolls

    GNU/Linux isn’t just a clone of Microsoft Windows and it oughtn’t be a clone of Microsoft Windows, either; some people set themselves up for failure, maybe by intention



  25. Centralised Git Hosting Has a Business Model Which is Hostile Towards Developers' Interests (in Microsoft's Case, It's an Attack on Reciprocal Licensing and Persistent Manipulation)

    Spying, censoring, and abusing projects/developers/users are among the perks Microsoft found in GitHub; the E.E.E.-styled takeover is being misused for perception manipulation and even racism, so projects really need to take control of their hosting (outsourcing is risky and very expensive in the long run)



  26. Links 29/11/2021: FWUPD's 'Best Known Configuration' and Glimpse at OpenZFS 3.0

    Links for the day



  27. President Biden Wants to Put Microsofter in Charge of the Patent Office, Soon to Penalise Patent Applicants Who Don't Use Microsoft's Proprietary Formats

    The tradition of GAFAM or GIAFAM inside the USPTO carries on (e.g. Kappos and Lee; Kappos lobbies for Microsoft and IBM, whereas Lee now works for Amazon/Bezos after a career at Google); it's hard to believe anymore that the USPTO exists to serve innovators rather than aggressive monopolists, shielding their territory by patent threats (lawsuits or worse aggression) and cross-licensing that's akin to a cartel



  28. Microsoft GitHub Exposé — Part VIII — Mr. Graveley's Long Career Serving Microsoft's Agenda (Before Hiring by Microsoft to Work on GitHub's GPL Violations Machine)

    Balabhadra (Alex) Graveley was promoting .NET (or Mono) since his young days; his current job at Microsoft is consistent with past harms to GNU/Linux, basically pushing undesirable (except to Microsoft) things to GNU/Linux users; Tomboy used to be the main reason for distro ISOs to include Mono



  29. Dr. Andy Farnell on Teaching Cybersecurity in an Age of 'Fake Security'

    By Dr. Andy Farnell



  30. IRC Proceedings: Sunday, November 28, 2021

    IRC logs for Sunday, November 28, 2021


RSS 64x64RSS Feed: subscribe to the RSS feed for regular updates

Home iconSite Wiki: You can improve this site by helping the extension of the site's content

Home iconSite Home: Background about the site and some key features in the front page

Chat iconIRC Channel: Come and chat with us in real time

Recent Posts