Bonum Certa Men Certa

Making JavaScript Suck Less

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)

Recent Techrights' Posts

Many Anniversaries
Many anniversaries in quick succession
 
Signs That XBox as a Console is Coming to an End, Windows Gaming Will be Called "XBox"
"XBox" is the next "Surface"
Microsoft's Share in Search Falls Sharply in Europe
The layoffs at Microsoft's Bing will carry on
Romania: GNU/Linux Reaches 4% (Less Than EU Average)
We expect this same upward trend to carry on
Microsoft Sites or Sites Sponsored by Microsoft Angry That GNU/Linux is Gaining
The Microsofters cannot easily dismiss reports of GNU/Linux growth as "bots" or just allege that statCounter alone is wrong
Ableism in the Free Software Movement Typically Comes From GAFAM Operatives and Proprietary Software Apologists
And their hired guns
Afghanistan: GNU/Linux Steadily Rises to 9%
Windows is steadily declining
IBM Innovation: It Has Invented New Methods of Silent Layoffs or Secret RAs
How IBM disguises mass layoffs now
LLM Slop Won't Replace People and Jobs (in the Long Run)
At the end of the day, people who know their job offer more useful information, whereas LLMs waste people's time (typically an 'externality' to the entity deploying chatbots)
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Monday, August 03, 2026
IRC logs for Monday, August 03, 2026
Over 3,500 Known Gemini Capsules Accessible and Active According to Lupa
It finally happened this morning
Gemini Links 04/08/2026: Library Cards, Dead Ends in Software Development, and DOS on USB Key
Links for the day
IBM Has Embraced and Rewarded Liars
The IBM culture vanished
statCounter Estimates GNU/Linux at 5.32% in Kuwait, Years Ago It Was Near 0%
Kuwait rose to fame in the 1990s because of a war
Swatting People Who Write About Corruption, Misogyny, Criminal Misuse of Funds
we've given ourselves a decade to cover all those stories
GNU/Linux Rises Above 6% in Colombia
In Colombia, which is a large south American country, GNU/Linux has risen steadily in recent years
SLAPP Censorship - Part 138 Out of 200: Garrett Has Basically "Lost" and It is "Embarrassing" to Them
they just wound up costing hundreds of thousands of pounds
Gemini Links 03/08/2026: Great Exodus, xkcd as Text, and Dead Ends
Links for the day
GNU/Linux Has Surged to 6.3% in Madagascar
Madagascar's adoption of Free software is a subject we covered a lot in past years
Microsoft's Slop Bet is Killing the XBox Even Faster
LLMs destroy almost anything they touch
The Cyber Show on "Weaponised Antisocial Technology"
by Andy
Alexandre Oliva on Slippery Slop (LLMs)
By Alexandre Oliva
RMS Won the Argument and Now GNU Wins Over Computer Users
He can look back at nearly 43 years of GNU and say, "I was right..."
statCounter Corrects GNU/Linux Estimates, Now Measured at 9% Worldwide
Windows has sunk like a rock
GNU/Linux-Centric Blogs Belatedly Pick Up News About GNU/Linux Gains: 4-8% Depending on the Surveyor
more people will get curious and give it a go
Links 03/08/2026: Strike By Flight Attendants (WestJet) and Greedflation
Links for the day
Links 03/08/2026: EU Curtailed Slop, Frank Zappa Recalled
Links for the day
Daniel Pocock on Sky News This Morning
No harm done
Morten Linderud Has Helped Microsoft Put Locks (and Kill Switches) on the PCs of Arch Linux Users
"the first rule of "secure boot" is to disable "secure boot"
In Poor Peru, GNU/Linux Surges From 1% to 5% in a Few Years
Windows is dying
All Social Control Media is a Weapon (Against Its Users, Serving the Real Owners)
That social control networks are weaponised isn't a new concept
Fanning the Flames of Journalism
This week we have several surprises coming
Forcing the Slop Bubble to Implode Fully to Save the Economy From an Even Greater Collapse and Societal Harm
Let's blow up the bubble. The sooner, the better
GNU/Linux at 8% in Croatia
somewhat of a GNU/Linux adoption hotbed
It's Easy to Predict Microsoft Layoffs for October 2026 Because of the Financial 'Results' That Month (More Faking, More Secret Debt and Buzzwords to Perfume This Debt as "Investment")
From what we've read, Microsoft is silently laying off people this month based on LITE, which leads to PIPs
Not Hard to Guess Who Will Pay for IBM's Collapse (Due to False Statements Made to Shareholders), Red Hat May Disappear
IBM's leadership is never being punished for its failures
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Sunday, August 02, 2026
IRC logs for Sunday, August 02, 2026
Gemini Links 03/08/2026: Collectibles, Cities of the Red Night, and Lali Lambda
Links for the day
IBM's August 2026 Promotions (Annual Ritual) Can Turn Into a "Bloodbath" (RAs, Layoffs)
IBM Common Stock is set to open in the red (minus) on Monday
Microsoft Culture Explained by People Who Work at Microsoft
"Be ready for politicking and working over time and weekends."
Codes of Conduct Attract Hoarders and Sociopaths, They Are Intolerant Towards Good People
Codes of Conduct (CoCs) are also promoted using violence
XBox is in Trouble, Sunday News Shows How Serious a Problem It Now Faces
it seems impossible to resuscitate at this point
statCounter Observes GNU/Linux at 10% in Libya
this month statCounter finally sees GNU/Linux approaching "double-figures" there
Thailand: GNU/Linux Approaching 15%, Windows in a Freefall
It makes perfect sense for Thailand to adopt GNU/Linux for technical reasons, not just political reasons
GNU/Linux in Bulgaria Back Up
part of a trend in Europe
Cuba Sees Leap in GNU/Linux Usage, as Reported by statCounter
For the ordinary Cuban it makes sense to reduce a dependence on GAFAM
Gemini Links 02/08/2026: Drift, Crawlers in Gopher Space, Purpose, and Python
Links for the day
Links 02/08/2026: Some Large Slop Investors "Crumbling", Russia Intensifies Bombing of Kiev
Links for the day
IBMers Discuss Who Killed IBM (It Impacts Red Hat)
Fedora is fast becoming like another CentOS
GNU/Linux Rises to 6% in Mexico
Did the soccer (football) matches have some impact or just the "unknowns" being deciphered (or omitted) by statCounter?
GNU/Linux Leaps to 8% in Asia
In Asia, is it a bit higher because of GAFAM distrust? Maybe some other factor/s?
Clownflare Web Usage Survey: About 10% in North America Use GNU/Linux, Worldwide 6.7%
surveyors that showed GNU/Linux growth
SLAPP Censorship - Part 137 Out of 200: Discovering That Spending a Million British Pounds (1,348,250.01 United States Dollars) on Lawyers Cannot Take Down One's Critics
just outright bullying and criminality
Steam Survey, analytics.usa.gov, and statCounter All Point to GNU/Linux Gains (Again)
This must be very annoying to Microsoft
GNU/Linux Exceeds 6% in Spain
In recent years the "market share" steadily grew from 3% to over 6%
Brazil: GNU/Linux Record High, 5%
On average, GNU/Linux has evidence of growth in many countries this summer
Amid 2026 Bing Layoffs Microsoft Share in Search Collapses
How much longer before Microsoft throws in the towel or rebrands again?
United Kingdom: GNU/Linux up to 7%, ChromeOS Another 5% (Total 12%)
further significant gains for GNU/Linux this month
Links 02/08/2026: Cheeto "Blurted Out Vile Plot to Censor ABC"; New York Times Fights 'Intimidation'
Links for the day
Why Techrights Will Still be Active a Decade From Now
Techrights will carry on for many years to come
We Are Witnessing the End of IBM
IBM cannot find growth by moving downwards, by lowering standards
The Slop Presumption Rule
Tainting oneself can take one day
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Saturday, August 01, 2026
IRC logs for Saturday, August 01, 2026
Gemini Links 02/08/2026: Older Books, Esperanto Music History, and Slop Making Things Worse
Links for the day