Skip to main content Skip to secondary navigation Accessibility Feedback

Just because someone doesn’t have JavaScript turned off doesn’t mean they have a JS-enhanced experience

From Craig McPheat on Twitter:

By default, JS is blocked on our corporate, virtualised Chrome. In the office, the only web I ever see is a progressively enhanced one.

A previous employer of mine had a similar approach to web security. There was a short whitelist of approved JavaScript files, and everything else was blocked. That meant that if your site was dependant on JS in any way, I had a pretty bad (or in some cases, unusable) experience.

Psst... I just launched a new guide to ditching jQuery for vanilla JS. Buy it today →

Not everyone who can’t use your JavaScript has JS turned off. Sometimes their employer is blocking the file. Sometimes there’s a bad link and the file 404s. Sometimes, you just missed a semicolon and the script breaks (don’t lie, you know it’s happened).

JavaScript is the most fragile layer in the front-end stack. When the browser sees a CSS selector or property that it doesn’t recognize, it skips it and moves on. When it encounters an HTML element it doesn’t recognize, it renders the element’s content and keeps going. And when it runs into a bug in your script, it stops running.

Start with semantic markup, add CSS for style, and then layer in JavaScript for an enhanced experience. Your critical content should always be accessible, even when JS fails to run.

If you liked this article, you might also like Ditching jQuery, my new beginner's guide to vanilla JavaScript. Buy it today →

Have any questions or comments about this post? Email me at chris@gomakethings.com or contact me on Twitter at @ChrisFerdinandi.

Get the Weekly Digest