On Javascript

(posted in tech)

Sorry, you need Javascript enabled to view posts on this blog.

Just kidding.

In the Hacker News discussion that sprung up around my expulsion story, one of the larger sub-threads was focused on the fact that the blog theme I was using at the time required Javascript to display the content.

This site “requires” JS because… The opacity of the article is set to 0? Everything’s there, everything’s rendered, but they have a CSS rule (“.use-motion .post { opacity: 0; }”). Only thing I can think of is that they do a JS fade-in or something and missed the unintended consequences.

That’s exactly what the theme was doing—it defaulted the entire site to zero opacity, and animated everything into view after the page loaded. I knew the theme was doing something like that when I originally chose it, but I did not realize that the theme rendered the site unreadable when viewed with Javascript disabled. I’ve since switched the theme to a modified version of Vapor by Seth Lilly, which I like better anyway (I’ve been using something similar on my fiction blog for a long time now).

The discussion generated a lot of passionate comments on both sides of the Javascript issue. Some against:

There’s no reason for websites that are just documents to not work with javascript disabled. For that matter there’s no reason that they shouldn’t work in text-based browsers… And with modern tools, there’s no reason that anything—even a highly interactive app—couldn’t be prerendered on the server.

…Requiring javascript to just view a blog article is insane.

…The text is in plain format in the source file. What does the JS add besides actually showing the text. Nothing. In 1999 the Web had aligned text, fonts, and hyperlinks. In 2015 we need JS to do this!?

And some not so against:

It sounds like you’re in favor of sending pdf’s around. Or probably more accurately, large bitmaps.

When the percentage of users using IE6 was lower than a few percentile, we started to ignore those users and came to expect that the web would be somewhat broken for them. Likewise, the web is becoming somewhat broken for users that have JavaScript turned off…

oh come on. It’s 2015, not 1999. If you don’t have javascript enabled, do you honestly expect to be able to read half of the internet?

It seems like this is one of those hot button topics in tech that can spark a holy war. Vim vs Emacs, anyone? (Just kidding, everyone with more than half a brain knows that Vim is far superior.)

Personally, I fall somewhere in the middle on the issue. I agree that frivolous use of Javascript to do things like animating page transitions is a bad practice. Not because I strongly believe that the entire web should be accessible and 100% functional without Javascript, but rather because doing that kind of stuff is super annoying. The absolute worst manifestation is those ridiculous “parallax” scrolling sites (usually the landing/marketing page for the latest new startup’s Web-5.0 product).

I initially tolerated the fading and hide-and-show sidebar on this blog because I thought they were pretty minor annoyances, and otherwise liked the layout and readability of the theme a lot. It did always nag at me though, and I had more or less decided to eventually switch over to my Vapor-based theme even before the HN discussion (I was procrastinating because it meant having to tweak it to support things I use on this blog like an archive page and code blocks).

All that being said, I think that my opinion of Javascript and client-side scripting is fundamentally different from the (I suspect small but vocal) group of people who eschew it entirely. It’s not an unreliable feature of browsers to be used only for gimmicks or adding optional value to an otherwise static web—it has become a fundamental component of the web’s delivery mechanism. I don’t think it’s unreasonable at all to assume that all of your users are on a modern web browser with Javascript enabled. For better or worse, the world wide web has long ago graduated from simple hypertext documents to a full-fledged multimedia application platform, and client-side scripting is an essential part of that. If some dude wants to write his blog using the hottest new single-page responsive JSON-powered web framework, more power to him! As long as it’s done tastefully and isn’t a kludge to use, I’m down with it.

The argument that there’s no reason a website’s content shouldn’t be viewable without Javascript simply doesn’t hold water for me. Like it or not, web browsers aren’t just document viewers any more. That may make you sad (I am certainly not happy about it—in my dream-world gopher won the battle and the world wide web doesn’t even exist), but just closing your eyes, plugging your ears, and singing LA LA LA LA isn’t going to make that fact any less true.

I find the argument that it’s inconsiderate and wasteful to relegate site functionality onto multiple client machines versus doing the work only once on the server to be equally fatuous. Why stop at Javascript? Isn’t it inappropriate to force all those client machines to parse your CSS and render the site’s styling? Servers should pre-render all their content! And how egregious of them to force all those poor client machines to spend valuable GPU cycles displaying that pre-rendered content. All servers should have an option to have their content printed and snail-mailed!

I agree that the web has ballooned into an ugly, ridiculous beast that relies way too heavily on client-side scripting for things that could easily be done without it, but I’m not so entitled to think it should revert to some previous glory-days version of itself to suit my personal biases. I leave Javascript enabled by default because there’s no escaping the fact that a large part of the web doesn’t function without it. When sites use Javascript in ways that I find offensive (privacy invasion, dumb content-blocking subscription popups, interstitial ads), I solve my problem (and it is my problem, not a problem with the sites) by either a) using browser extensions like uBlock Origin, RefControl, and Self Destructing Cookies to consume content in a way I can live with, or when that doesn’t work, b) just not visiting those sites anymore.

There are other reasons that people refuse to use Javascript that I haven’t really addressed here. Security concerns are valid; I use Firefox and have sufficient trust in Mozilla’s ability to protect me from anything truly malicious, but I can empathize with people who feel differently. There are also those who refuse to use anything other than free-as-in-speech software; I have a difficult time understanding the motivations behind that mindset, so can’t really comment.

To everyone who NoScripts their way through life, I say this: Even though I’m not joining your battle, I sincerely hope you win it in an epic David-beats-Goliath way. And if you can find a way to bring gopher back as a serious thing to replace the web once and for all, let’s do that too. I’m quite certain I’ve pushed a few buttons with the opinions I’ve expressed here, but I hope you can forgive me both for that, and for my blunder with the blog’s previous theme.

Short Permalink for Attribution: rdsm.ca/3ch27