|
| 1 | +# JavaScript abuse |
| 2 | + |
| 3 | +> [!note] |
| 4 | +> This blog-post is WIP/unfinished. |
| 5 | +
|
| 6 | +I'm not here to tell you "JS bad", because many people have already done that: |
| 7 | +- [`/denysdovhan/WTFJS/`](https://github.com/denysdovhan/wtfjs) |
| 8 | +- [`/brianleroux/WTFJS/`](https://github.com/brianleroux/wtfjs) |
| 9 | +- [YLS](https://wiki.theory.org/YourLanguageSucks#JavaScript_sucks_because) |
| 10 | + |
| 11 | +I'm writing this for other reasons: |
| 12 | +- spreading awareness of the crap that `noscript` users have to deal with, and how this effects "[normies](https://en.wiktionary.org/wiki/normie)" as well |
| 13 | +- venting, because I'm **fucking sick of this shit** |
| 14 | +- propose alternatives, for people with _good intentions™_ |
| 15 | +- shame and mock entities that are incompetent, don't care, or willfully do this shit |
| 16 | +- a cry for help, coming from a developer who was forced to deal with piles of abstractions (React + Redux + MaterialUI + ReactRouter = **NIGHTMARE**) |
| 17 | +- the accessibility challenges of dynamic content |
| 18 | +- how this connects to [enshittification](https://consumerrights.wiki/w/Enshittification) and [bloat](https://consumerrights.wiki/w/Bloatware) |
| 19 | + |
| 20 | +Keep in mind, **I ain't a luddite**. And I don't hate JS in particular. I love when JS is used right! such as: |
| 21 | +- [Demoscene](https://github.com/Rudxain/RGB-digital-rain) |
| 22 | +- [Competitive stuff](https://gist.github.com/Rudxain/c06a6800807233fe6e74f179dda750a8) |
| 23 | +- Make [an abomination](https://github.com/Rudxain/ideas/blob/aa9a80252a4b7c9c51f32eda5c716e96220ed96e/software/evar/with_bf.js) for fun, and to [prove a point](https://github.com/Rudxain/ideas/blob/aa9a80252a4b7c9c51f32eda5c716e96220ed96e/software/evar/README.md#why)! |
| 24 | +- Even [coding as a form of art](https://gist.github.com/Rudxain/f4d2dd9b1c3e44a2eb4fb46ddf2a76f6#file-minimum-bit-length-js-L58-L77) ✨ |
| 25 | + |
| 26 | +Notice how the "competitive" one abuses ES/JS behavior to optimize the size of the program. That's called _code-golfing_, and it's totally acceptable to break best-practices to reach your goal, simply because the result pushes the boundaries of what was believed to be possible, and that's _cool_, not _disgusting_. |
| 27 | + |
| 28 | +## Sources |
| 29 | +- [LibRedirect explaining why it exists, and how MV3 limits it](https://libredirect.github.io/faq.html) |
| 30 | +- [gluegle has beef with Firefox users](https://github.com/uBlockOrigin/uBlock-issues/discussions/3240) |
| 31 | +- ["meta" inc, spitting in your face](https://github.com/Rudxain/uBO-rules/pull/9) |
| 32 | +- [`noscript` treated like 2nd-class citizen](https://github.com/Rudxain/uBO-rules/blob/42220bd4f80052ee15136dff7269df19529c43ec/rx.abp#L69-L76) |
| 33 | +- [websites being obnoxious to `noscript` users](https://github.com/iam-py-test/my_filters_001/blob/fc5f61eff0b0d821cb426bea76b18937072bc390/no-js-warnings.txt) |
| 34 | +- [disbloat](https://github.com/Rudxain/uBO-rules/blob/42220bd4f80052ee15136dff7269df19529c43ec/rx.ubo#L3-L19) |
| 35 | +- ["Enough with the JavaScript already!"](https://www.slideshare.net/slideshow/enough-withthejavascriptalready/23262138) |
| 36 | +- ["Maybe we could tone down the JavaScript"](https://eev.ee/blog/2016/03/06/maybe-we-could-tone-down-the-javascript) |
| 37 | +- ["You don't need JavaScript for that"](https://www.htmhell.dev/adventcalendar/2023/2/) |
| 38 | +- ["You really don't need all that JavaScript, I promise"](https://www.kryogenix.org/code/dont-need-that-js) |
| 39 | +- https://jakearchibald.com/2013/progressive-enhancement-still-important |
| 40 | +- [Unobtrusive JS](https://www.w3.org/wiki/The_principles_of_unobtrusive_JavaScript) |
| 41 | +- ["Everyone has JS, right?"](https://www.kryogenix.org/code/browser/everyonehasjs.html) |
| 42 | +- [The humble "grug-brain" developer](https://grugbrain.dev) (this is for the "cry for help" part) |
| 43 | +- [Web Obesity Crisis](https://idlewords.com/talks/website_obesity.htm) |
| 44 | +- [JS bloat (2024)](https://tonsky.me/blog/js-bloat) |
| 45 | +- [Software disenchantment](https://tonsky.me/blog/disenchantment) |
| 46 | +- https://www.gnu.org/philosophy/javascript-trap.html |
| 47 | +- https://www.gnu.org/philosophy/wwworst-app-store.html : [I don't agree with this](re_twwwas.md), but I love the ending! |
| 48 | +> if you wish your site to give its users a taste of how the WWWorst app store feels to us, add to web pages you control the following JavaScriptlet: |
| 49 | +> ```js |
| 50 | +> document.body.textContent = 'Please disable JavaScript to view this site.' |
| 51 | +> ``` |
| 52 | +- [🖱️Click ×4](https://clickclickclick.click): this is about tracking/privacy-invasion |
| 53 | +
|
| 54 | +## to-do |
| 55 | +[These exception-filters](https://github.com/uBlockOrigin/uAssets/blob/30c5cbc78a4625ab02a1a1a52d898102da7eb58a/filters/filters-2021.txt#L4128-L4132) prove that enshittification effects everyone. I had to rewrite [one of my filters](https://github.com/Rudxain/uBO-rules/blob/42220bd4f80052ee15136dff7269df19529c43ec/rx.abp#L112) because I never allow JS on windowscentral, so I never need to prevent uBO from being detected. The uBO team is forced to design filters for the lowest-common-denominator, leading to sad stuff like that. |
| 56 | +
|
| 57 | +If you visit any [Discourse](https://discourse.org) forum, you'll notice they have [graceful degradation (not PE)](https://www.w3.org/wiki/Graceful_degradation_versus_progressive_enhancement). However, if you visit it using a phone, you'll be greeted by this ✨ _wonderful_ ✨ message: |
| 58 | +
|
| 59 | +> "HTML content omitted because you are logged in or using a modern mobile device" |
| 60 | +
|
| 61 | +```rust |
| 62 | +for _ in 0..=u16::MAX { |
| 63 | + println!("WHY?"); |
| 64 | +} |
| 65 | +``` |
| 66 | +
|
| 67 | +I'll ~steal~ borrow [a quote](https://blog.vaxry.net/articles/2025-dbusSucks): |
| 68 | +> Honestly, I am at a loss of words as to how to describe this without being extremely rude. |
| 69 | +
|
| 70 | +## Unreliable color-scheme |
| 71 | +We need to talk about dark and light modes. Yes, this is **so bad that it needs its own section**. |
| 72 | + |
| 73 | +Let me preface by asserting that your page **only needs [1 line of HTML](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meta/name/color-scheme)** to support both preferences: |
| 74 | +```html |
| 75 | +<meta name=color-scheme content="light dark"> |
| 76 | +``` |
| 77 | +That's it! Just add that inside the `<head>` and your pages now can **automatically** ("dynamic" if you will) switch between both themes in *real-time*, adapting to user preference! |
| 78 | + |
| 79 | +This is not new, it has existed for many years. No need to worry about "compatibility"! |
| 80 | + |
| 81 | +I can already hear you complaining: |
| 82 | +> But the default browser stylesheet is ugly! |
| 83 | +
|
| 84 | +or: |
| 85 | +> But I **NEED** my pages to look the same in all browsers! |
| 86 | +
|
| 87 | +or: |
| 88 | +> But I have a _Brand™!_ I have my own stylesheets to theme my site! |
| 89 | +
|
| 90 | +Fine, [here you go](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-color-scheme): |
| 91 | +```css |
| 92 | +/* default light */ |
| 93 | +html { |
| 94 | + background: #ccc; |
| 95 | + color: #111; |
| 96 | + /* etc... */ |
| 97 | +} |
| 98 | +/* conditional override */ |
| 99 | +@media (prefers-color-scheme: dark) { |
| 100 | + html { |
| 101 | + background: #111; |
| 102 | + color: #ccc; |
| 103 | + } |
| 104 | + /* etc... */ |
| 105 | +} |
| 106 | +``` |
| 107 | +No excuses! |
| 108 | + |
| 109 | +> But I **NEED** it to be configurable! |
| 110 | +
|
| 111 | +...why would you want that? It already is? |
| 112 | + |
| 113 | +> No! We want an obvious UI that allows users to choose a theme that doesn't match the browser! |
| 114 | +
|
| 115 | +Again, _why_ would you want that? Are your users complaining about "lack of choice"? |
| 116 | + |
| 117 | +> No...? |
| 118 | +
|
| 119 | +Then shut up. |
| 120 | + |
| 121 | +> But- |
| 122 | +
|
| 123 | +**OK FINE!!!** If you insist, just use a [`<form>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/form) to take input and send it to the server, then the server response should [set a cookie](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Cookies) on the client, to remember the preference. Are you happy now? |
| 124 | + |
| 125 | +> but- |
| 126 | +
|
| 127 | +Now that the preface is done, [let me tell you how much I despise](https://youtu.be/EddX9hnhDS4) youtube! |
| 128 | + |
| 129 | +### youtube |
| 130 | +YT theme requires JS to detect preference: |
| 131 | + |
| 132 | +This is bad, but it's "forgivable" since YT needs JS for many things. However, it's worth noting that **YT remembers the last preference**. I know because the server returns a page colored like my last visit. This is better than other sites, which fallback to a hard-coded stylesheet (_\[cough\]_ disbloat _\[cough]_) |
| 133 | + |
| 134 | +YT theme **needs a full-page reload** to apply... |
| 135 | + |
| 136 | +wait, **WHAT?!** |
| 137 | + |
| 138 | + |
| 139 | + |
| 140 | +what 👏 is 👏 the 👏 point 👏 of 👏 a 👏 "dynamic" 👏 language? 👏 |
| 141 | + |
| 142 | +seriously, **WHAT IS THE DAMN FUCKING POINT OF JS IF YOU NEED TO RELOAD ANYWAYS‽‽‽** |
| 143 | + |
| 144 | +**WHAT HAPPENED TO** _"[single-page application](https://en.wikipedia.org/wiki/Single-page_application)™"_**‽‽‽** |
| 145 | + |
| 146 | +**AND THEY HAVEN'T FIXED THIS FOR YEARS!!!** |
| 147 | + |
| 148 | +And you know what's worse? That "Device theme" option (the one that "adapts" to your preference) **requires you to manually reload the damn page** just so that YT notices the change. |
| 149 | + |
| 150 | +Have they heard of [`matchMedia`](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia)?: |
| 151 | +```js |
| 152 | +const light_query = matchMedia("(prefers-color-scheme: light)"); |
| 153 | +// sync |
| 154 | +let is_light = light_query.matches; |
| 155 | +// async |
| 156 | +light_query.addEventListener("change", (e) => { |
| 157 | + is_light = e.matches; |
| 158 | +}); |
| 159 | +``` |
| 160 | + |
| 161 | +What kind of incompetence YT has??? No sane human should think that is "acceptable"! |
| 162 | + |
| 163 | +But nooo, [they're too busy fighting ad-blockers](https://consumerrights.wiki/index.php?title=YouTube&oldid=31465#Crackdown_against_ad-blockers), so they end up being ["resource constrained"](https://idlewords.com/talks/website_obesity.htm#:~:text=Google%20was%20%22resource%20constrained%22) to actually improve [UX](https://en.wikipedia.org/wiki/User_experience) |
| 164 | + |
| 165 | +Let's take a moment of silence to pray for our beloved YT... |
| 166 | + |
| 167 | +After a word from our sponsor! **RAID SHA-** 🔫💥 |
| 168 | + |
| 169 | +### Wikipedia |
| 170 | +I respect WP, [I even like it](https://en.wikipedia.org/wiki/User:Rudxain), but I'm sorry, nobody can convince me that WP is "struggling" to implement auto-color-scheme for more than 6 years, that's plain bullshit. |
| 171 | + |
| 172 | +The [CRW](https://consumerrights.wiki/) is powered by MediaWiki as well, and its theme is **fully adaptive** without JS. So why does WP still consider "Auto" an "experimental feature"? and why does it require JS? |
| 173 | + |
| 174 | +WP has **much** more money and contributors/volunteers than CRW, and they still fail to provide such a simple feature? |
| 175 | + |
| 176 | +I'm sorry, again, if anyone gets offended, but this implies that WP doesn't care about its users. And if they do care, they're lazy and incompetent. There is no other explanation. |
| 177 | + |
| 178 | +### Me? |
| 179 | +Roasting others is unfair, so here I'll roast myself, for the sake of "redemption". |
| 180 | + |
| 181 | +If you've visited my GH-Pages site, you'll quickly notice that I'm a hypocrite! All of my pages (except for RGB-DR) are either `light` or `dark`, even with JS enabled. |
| 182 | + |
| 183 | +I'd like to [blame Jekyll themes](https://github.com/Rudxain/Rudxain.github.io/issues/9) for this, but this is my mistake, and I have to deal with it. |
| 184 | + |
| 185 | +Don't worry, [I'm working on fixing it](https://github.com/Rudxain/Rudxain.github.io/pull/15)! |
| 186 | + |
| 187 | +## Not all is bad |
| 188 | +I don't want you, dear reader, to feel like a [doomer](https://www.urbandictionary.com/define.php?term=doomer)/[gloomer](https://www.urbandictionary.com/define.php?term=gloomer) after reading this. So here are some good news to give you hope! |
| 189 | + |
| 190 | +- There's [many people in favor of simpler web development](https://github.com/lyoshenka/awesome-motherfucking-website)! |
| 191 | +- There's [a big community pushing back against sloppy and/or corporate software](https://handmade.network/manifesto)! |
| 192 | +- Someone made [this parody (not satire) site](http://vanilla-js.com), lol |
| 193 | +- People do amazing things with only HTML and CSS: |
| 194 | + - [vereis theme](https://github.com/vereis/blog/issues/2) |
| 195 | + - [YDNJS](https://github.com/you-dont-need/You-Dont-Need-JavaScript) |
| 196 | + - [1HTML challenge](https://github.com/Metroxe/one-html-page-challenge) |
| 197 | + - [CSS Zen Garden](https://csszengarden.com) |
| 198 | +- SoundCloud (yes, [that one](https://consumerrights.wiki/w/SoundCloud)!): A few weeks ago, their pages now show _more_ content than before! (in `noscript`). Previously, it was just a generic page telling you to enable JS. I wish I could say they care about `noscript` users, but they don't care about their users in general. I guess they're experimenting with [SSR](https://en.wikipedia.org/wiki/Server-side_rendering) or [pre-rendering](https://vite.dev/guide/ssr#pre-rendering-ssg) |
| 199 | +- [Deno making dark-mode work in `noscript`](https://github.com/denoland/docs/pull/2709) |
| 200 | +- [ESlint team concerned about accessibility and productivity](https://github.com/eslint/eslint/issues/20279) |
0 commit comments