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

Machine-Generated Legal Documents, Over 2,000 Pages Sent to Us Today Alone
We now know that the papers we receive are produced using bots (algorithms)
2026 Microsoft Mass Layoffs in So-called 'AI' Datacentres, Why Doesn't the Mainstream Media Cover The News?
What does this tell us about the state of the media?
"Over 1,100 Law Firms Gone in Five Years" in the United Kingdom (UK) Alone
There are basically way too many lawyers (looking for "business", e.g. threats and lawfare) and not enough positions to fill
Microsoft FUD From Microsoft Site Helps Distract From Actual Microsoft Back Doors
Published on a Sunday
IBM is Killing Red Hat's Portfolio - Including Linux - to Prop Up Ponzi Scheme ("AI")
IBM is killing Red Hat
Gemini Links 02/03/2026: Weird Phone Calls, Small Phones, and Exploring Racket
Links for the day
 
Tomorrow should be sunny (at long last!) and a generally productive dayProductive Week Ahead
Tomorrow should be sunny (at long last!) and a generally productive day
Only One Slopfarm Seems to Have Targeted "Linux" Today
It certainly does feel like the slop hype is reaching the "late life crisis" and companies that benefited from this bubble are overdue for a day of reckoning
Microsoft Mass Layoffs: Being Sacked at 1AM in the Morning
Watch what happens to Microsoft employees who get pregnant
Links 02/03/2026: More Social Control Media Bans, Climate Change Woes, and "Journalist With Germany's Deutsche Welle Arrested in Turkey"
Links for the day
Gemini Links 02/03/2026: Small Phones, "I 3D Printed My Brain", and "Managing 5 Servers at Once with tmux"
Links for the day
IBM is Trying to Hide Mass Layoffs, Not Only With NDAs and 'Scripted' LinkedIn Posts
From what we can gather (screenshot above), today many people leave IBM and Red Hat
Richard Stallman is Giving a Public Talk This Week (Friday in Lucerne School of Computer Science and Information Technology)
His birthday is just around the corner.
Windows Falls to New Low in World's Largest Population (India)
Windows is now down to 7%
Never Miss a Good Opportunity to Shut Up and Drink Coffee
Threats come at a cost; each time you issue a threat you stigmatise yourself as a bully
Last Month Matthew Garrett Said Ridiculous Things After His Spouse Had Called Him a "Rapist", Now He's Trying to Take the Site Offline and Put My Family in Prison
The real issue of concern to him (and his alleged reputation) is the spouse and the matter is to be dealt with in America, not the UK
Reporting to Our Politicians/MPs the Failure of the SRA to Stop Hired Guns Who Help Americans (Men Who Attack Women and Nowadays Also Attack British Reporters)
About a month ago my wife wrote to politicians to get the ball rolling
The Topic Many People Don't Want to Talk or Write About
"DEI" is inherently about making racial and gender patterns better reflect society's
XBox is Virtually Dead Already, What Next Will Die at Microsoft?
Now that there are mass layoffs at Microsoft datacentres it is not premature to speculate about what dies after XBox
For the First Time, statCounter Measures Internet Explorer at 0.01% "Market Share"
What Microsoft replaced it with is just a Chrome clone with extra spyware
Was a Lot of "Windows" and "Unknown" in Iran Just GNU/Linux in Disguise?
more than 1 in 10 desktop/laptop requests is estimated to be GNU/Linux
"Here in the UK, GNU/Linux rose to all-time high at Windows' expense"
Will this entail Software Freedom as well? This depends on all of us
Links 02/03/2026: Claude Code Causes a Mexican Government Cyberattack, "London Repair Week" Noted
Links for the day
Don't Fall for "Top X Law Firms" in "Discipline Y", They Pay $Z to Get False Endorsement/s
It's a scheme, a scam, an elaborate fraud
More Publishers Have Turned From Slop Boosters Into Slop Sceptics and Critics
There's a "hidden cost" when one participates (for profit) in "pump and dump" schemes
TeX Live Has New Release, But Planet Debian Won't Tell You That
It 'unpersoned' the developer
LLM Slop Does Not Know People (It Knows Nothing) and Cannot Distinguish Between People. It's a Recipe for Disaster.
no way of knowing who's who
Free Software Foundation Needs to Become More Active in Europe to Avoid Impersonation by Microsoft-Sponsored Groups
So far we've hardly seen the FSF saying anything at all about the US president
Links 02/03/2026: "Not Envious of Billionaires" and Palantir SLAPPs "Swiss Magazine For Accurately Reporting That The Swiss Government Didn't Want Palantir"
Links for the day
There Has Never Been a Better Time to Quit Social Control Media
Those networks are selling something. And that something is not peace because peace does not sell "attention".
Microsoft Users Drowning in Slop, If They Complain Microsoft Censors Them
Like an authoritarian regime
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Sunday, March 01, 2026
IRC logs for Sunday, March 01, 2026
Speed of Sites Matters
Being easily accessible all the time matters to us
Dr. Andy Farnell on "Good Tech"
in the age of "rent everything" and "own nothing"
Gemini Links 01/03/2026: Simpler Software and Announcing OFFLFIRSOCH (OFFLine-FIRst SOftware CHallenge) 2026
Links for the day
EPO "Cocaine Communication Manager" - Part V - Jobs at the EPO for Those Connected to Cocaine Addicts (Skills Not Required)
EPO management is trying to shoot the messenger
Booz Allen Hamilton, the Former Employer of Edward Snowden (NSA Contractor), is Drowning in Debt
Can Supreme Leader Cheeto bail it out like he does slop companies?
On the Concept of "Protected Class" (or Race) at IBM
It's self-harming as in practice it imperils the company and harms the reputation/brand
The Mass Layoffs at Microsoft That Nobody in the "News Industry" Wants to Talk About (and TheLayoff.com Censored, Then It Censored the Evidence of the Censorship)
They basically cover up how they censored the news about Microsoft layoffs
Richard Stallman to Give at Least Three Talks in Switzerland, Starting This Week
No mention (yet) of the Bern talk
On Who 'Speaks for' Techrights
typically a case of misrepresenting the site
'FSFE' an Imposter in Europe, Paid by GAFAM to Represent GAFAM Interests
The Microsoft-sponsored 'FSFE', which violates the terms of use of its name, is causing confusion [...] formally-recognised institutions got tricked into thinking that the Microsoft-sponsored 'FSFE' is the FSF
Lots of Lies From the Slop Industry
The slop industry relies on fake news to give a notion or fake demand
Links 01/03/2026: American Plutocrats Buy American Media While American Constitution Shredded
Links for the day
Teaser: The Next Series About the SRA, Which Would be Just as Effective as It Is Right Now If It Had Zero Employees
the lapdog (of the "litigation industry") that is meant to be perceived as a watchdog
Solicitors Regulation Authority (SRA) Inaction and Incompetence - Part I - Introduction
The SRA is a sham. Many people know this already, but we want to document our own experiences with it.
Live Simply, Live Better
Life isn't about "collecting" possessions; it's about doing things that matter and accumulating knowledge so as to make better choices
Now That XBox is Pretty Much Dead and There Are Mass Layoffs at Microsoft
This means our predictions about Microsoft (and XBox) are "falling into place"
Gemini Links 01/03/2026: "In the Spirit of OFFLFIRSOCH" and "Delete Patreon"
Links for the day
ACM Lowers Its Standards for Age of Autocracy
IBM is more than happy to work with autocracies
The term FUD (fear, uncertainty, doubt) was created to describe IBM's tactics and IBM is doing it again
Rob Thomas or "RT"
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Saturday, February 28, 2026
IRC logs for Saturday, February 28, 2026
Slop is Distraction
LibreWolf will never include any of this slop nonsense, no matter if toggled on or off
Cult inquiry: Parliament of Victoria, last chance to have your say
Reprinted with permission from Daniel Pocock
Internet Relay Chat (IRC) Turns 37.5
Can IRC reach age 75?
Gemini Links 28/02/2026: Loadbars 0.13.0, IME (Input Method Editor), and ColorColumn in Vim
Links for the day
Two EPO Strikes in March (Maybe More)
As per the SUEPO diary [...] We still have an ongoing series about the EPO, with several more series to start later
Why We Are Concerned About the SRA's Failure and What That Means to the Profession of Lawyers in the UK
Unregulated industries will lose their credibility as there is a threat of growing perception that they operate outside the law rather than practice law
Over 10,000 Pages/Articles Per Year?
Probably my most productive month, ever
Keeping Techrights Online 99.99% of the Time
Some time later this year we'll tell a very long story about how extremists attacked our webhosts
Richard Stallman, Founder of the Free Software Movement, Will be Giving Public Talk in Bern (Switzerland) in Less Than 12 Days
We are still doing a series about him and his talks
Still Lots of IBM Departures
It's not that we lack evidence of IBM layoffs. It's just that we have ample evidence of the press not doing its job (or barely existing anymore).
The Register MS Standards: Promote a Ponzi Scheme in Exchange of Money
Once upon a time it was a serious publisher. Months ago it was taken over by a Microsoft person.
Slopfarms' Demise Looks Like the Beginning of the End (Lowered Demand for Slop)
Slop about "Linux" has gotten hard to find this past week
Dr. Andy Farnell: Time to Pull the Plug?
insightful, as usual
Links 28/02/2026: "Tehran’s Two-Tiered Internet", "Internet Under Fire"
Links for the day
When an Entire News Site is About One Topic (and One Topic Only)
Tomorrow we start a new series for the new month
Links 28/02/2026: Bill Epsteingate Admits Sex With Young Girls, "Epstein Files Are the Horror That Keeps on Giving"
Links for the day
IBM: Where Companies Come to Perish
thelayoff.com is censoring stories
Tech Layoffs Are Not Because of Slop, They're an Effect of a Rotting Economy and Tech Giants Being Too Deep in Debt
Block is rapidly sinking in debt
The Slopfarms' Business Case (or Business Model) Never Existed and Nowadays, in 2026, They've Mostly Collapsed
Hopefully by year's end many slop suppliers will be offline and slopfarms that rely on them throw in the towel
March in London Today Against Slop's Harms to Society (and the Environment), Starting at 12:00 GMT at the Microsoft OpenAI Office
Today there is a protest in London (UK)
Microsoft Mass Layoffs Have Officially Resumed, Microsoft's Waggener Edstrom/Frank Shaw Lied
"The former employees say this was a mass layoff"
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Friday, February 27, 2026
IRC logs for Friday, February 27, 2026