You don’t really need JavaScript for most websites. Even when you do need JavaScript, such as when your website is a web application (eg: Google Docs/MS Office), it is considered common courtesy to display a message saying “this website requires JavaScript to function.”
Some websites forgo the courtesy. YouTube will display nothing but empty <div> elements with white and grey background color styles. However, if I use an old browser agent (like Opera 12) YouTube will serve me with a legacy page.
Then there are websites that use CSS to hide everything if JavaScript is enabled. For example, every webpage associated with Politico sets the body element’s visibility to hidden. They are still sending me all of the bytes for the entire article. I can only assume that they hate people who browse without JavaScript.
Then you have websites where the developers put in the effort to send an error page with the message, “please enable JavaScript”, then promptly set the body element’s visibility style to “none”. Thus hiding the error and showing a blank page. One example is at http://www.aboutads.info/choices (redirects to http://optout.aboutads.info).
The Straight Dope works just fine - better, even - without JavaScript and is therefore immune to criticism on this issue.
My own website was designed specifically to work well without Javascript. It wasn’t even really all that long ago that assuming the user did not have Javascript was a requirement of a non-asshole website. On my site, you might have to click through a couple of levels of navigation instead of having popup menus, but you can get everywhere and enjoy all of the content without it.
Yes, the assumption now is that everyone runs JavaScript. The major web browsers haven’t had the option to disable JavaScript (other than for testing purposes while using the developer console) for years now. The only people who run without JavaScript are those who use extensions like NoScript, and then it’s expected that they will have to allow at least first-party scripts so the site will function.
Since only power users would ever have JavaScript turned off, it’s assumed that they’ll know that turning
JavaScript off must be what broke the page. Thus the warnings are no longer really considered necessary, and modern sites aren’t designed to degrade gracefully.
Hiding the body tag isn’t done to make the site not work for people with JavaScript disabled. It’s just done to hide the page until the JavaScript has been loaded. CSS has to be read before the page is displayed, but JavaScript generally kicks in after the page has already loaded. They’re doing it so that people don’t see an incompletely loaded site. This isn’t standard–the conventional wisdom is that users perceive the site as faster if they see it while it is loading–but it is sometimes done.
And if some older framework does display an error about JavaScript being disabled, most want to hide this, as it is much, much more likely that the JavaScript is just taking a bit longer to load (due to a bad connection, the computer being busy, etc) than it is that someone in 2020 is actually surging the web with JavaScript disabled and has forgotten.
You have a point there, although I think hardware and software constraints are a factor, too. Until very recently my phone did not support JS at all. Many of my other devices, such as my iPod or Kindle, do not support JavaScript.
I have also disabled JavaScript on my ten-year-old laptop, which has the capability but not the security. Some of the computer hardware at work is over fifteen years old, but we can’t replace them because critical and expensive peripherals require that environment. And then I still get a call every couple of months from someone who is trying to view our website with “Netscape” or “Internet Explorer” on an XP machine. They might not have disabled JavaScript, but some manner of viruses or junk addons disable it for them.
Ha! I’ve been suggesting for years that things go better (mostly) without JavaScript, but everyone here just jeers.
When I find a site that is totally non-functionas without JS, especially if all I see is a blank screen (like Politico), my first reaction is to try disabling Styles rather than enabling JS. (Safari has it on the Develop menu. Firefox, last I looked, has it on the View menu.)
What that gives you is a totally unformatted page, which is ugly but in many cases still quite easily readable. For sites that are mainly just text, like news sites, that should be just fine.
Note, when you enable JS, you have to re-load the page for it to take effect. When you enable or disable Styles, you don’t.
What pisses me off is the amount of stuff people pile into their web sites that depends on JavaScript that doesn’t have to be dependent on JavaScript.
I’ve been saying for decades that the requirements of a site should be dictated by its content. If your content is primarily or entirely text, like most news stories, then it should work just fine in a 1995 copy of Lynx. If pictures are an integral part of your content (note: This is not the same thing as “pictures enhance the experience”), then obviously Lynx won’t work, but Mosaic still should. It’s fine if what Mosaic displays isn’t as pretty as a modern browser, but it should still work. If your content is a browser game, or a calculator, or the like, then in that case, yes, you can require Javascript.
On another note: Being able to set the size of elements, so the rest of the page will load in the correct locations around them, has been a part of HTML since at least the 90s. So many pages nowadays don’t make use of that, and there’s no excuse whatsoever for it. So often, when I’m reading a page, all of a sudden everything will jump half a page downward to accommodate an ad that just loaded at the top of the screen, and then jump back when that ad collapses itself, and then compresses down to half-column width for an ad on the side, and so on until the page completely finishes loading (which typically takes longer than the time to read an entire article, any more). If you really need all of those ads, well, I’m not crazy about that, but that’s your decision. But set aside the space for the ads at the start, and then load them in those spaces, so I can actually read your content.
This also pisses me off to no end. It’s not just ads, either. The business webapplications I have to use seem to have abandoned the concept of presenting a smooth user interface. The page jumps around all the time, and one of my employees actually quit in part citing how all of the shifting gave her headaches.
I like the idea of progressive enhancement, but I can understand if web developers don’t want to put in the effort if they don’t have a business need to do so. But if the new paradigm is to shove traditionally server-side processing onto the client, or to simply cover up the page to mask poor execution (as BigT suggested of Politico), that’s just lazy.
I wasn’t necessarily suggesting poor execution–though that is a possibility. I meant more that it hides the page until it’s actually functional. This amount of time will be quite quick, less than half a second.
That said, Politico may have another reason, now that I think about it. It may instead be blanking the page to discourage people from using adblock. They hope that people running adblock will block the script that makes the page visible, and then think they need to turn adblock off to read the page.
Granted, this doesn’t tend to work very long, as people will figure out what’s happening and fix the adblock rules. But I’ve seen plenty of companies try.
Similarly, some times may do it to try and discourage getting around a soft paywall by turning JavaScript off.
And, as for Chronos’s claim: positioning everything is practical if you (1) know the size of all elements ahead of time and (2) are designing the site with code specifically for that page. Most often, one or both of these isn’t the case. People use frameworks and just add their own content, so the framework has to accommodate any size.
And the ad probably deliberately made itself larger to draw attention to it. The page owner doesn’t know how big it will be, and has only copied and pasted code that the ad provider told them to use. So it’s all on the ad makers, including why the ads are so large they can’t finish loading before you’re finished with the page.
Adblockers serve three purposes–blocking annoyances, adding security (as you don’t run rogue JavaScript or some WebAssembly), and it allows pages to load faster with fewer resources. I encourage using it whenever you can–you can always pay $1 a month on Patreon for creators who actually need the money. Even if you only do it for a month, you’ll give them more money than they’d get if you allowed ads.