HEY STUPID: Stop polling localStorage without a try/catch!

I’m going on a rant against my fellow programmers, because there are a lot of JavaScript developers out there working on commercial websites who ought to frelling know better. This also applies to older versions of the Modernizr script, although newer ones fixed that so if you’re using an old one, UPGRADE!

Here’s the deal: Some of us are careful about cookies. You might say overly paranoid, but whatever. I only allow cookies by whitelist. This can cause problems when I’m using a site for the first time, as I may have to allow cookies for a few domains, but it’s not a problem for sites where I actually have any interest in allowing cookies. And yes, I know there are extensions now that I can use that will simply delete cookies after a short time if I don’t whitelist, but again that’s not the point. Anyway it’s usually not a problem to enable cookies for the domains I care about. It’d be easier if some version of Firefox a while back hadn’t changed things so it cared about whether I’m using HTTP or HTTPS as the protocol, in which case I often have to set an exception twice.

But there are sites that handle this badly, and for absolutely no reason. One of their core scripts looks for localStorage, or sessionStorage, or indexedDB, and this throws a security error if the browser has cookies disabled. So even if the site doesn’t need to set any cookies to operate properly, it fails. And worse, many sites fail to render entirely if that one script they’re relying on throws everything into chaos, all because some STUPID STUPID STUPID JavaScript programmer didn’t use a try/catch.

Disabling cookies ought to prevent proper logins; I accept that. I can see other reasons it could be an issue for certain functionality. What it should not do is prevent the website from functioning entirely, or worse, reload over and over as I’ve sometimes seen. That’s astonishingly bad behavior.

What makes this worse is that web developers are cautioned to always do things in a way that fails gracefully if JavaScript itself isn’t available. Personally I find that a tad extreme, but some basic version of a site should at least be visible instead of a blank page. But here, because of one security exception thrown by the browser, the entire content of a page fails to load and I’m stuck looking at absolutely nothing.

And usually this is only happening because of some simple check early in said script to try to detect a browser or some crap. They’re not even using the capability, but checking for it when it’s not allowed WILL throw an exception which WILL cause problems if you don’t freaking catch it!

The target of this rant, by the way, is twitch.tv. I just followed a link there only to be greeted by the Nothing.

Get your crap together, guys. You’re an embarrassment to the profession.

About Lummox JR

Aspiring to be a beloved supervillain
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s