this post was submitted on 26 Jan 2023
11 points (100.0% liked)
General Programming Discussion
7816 readers
2 users here now
A general programming discussion community.
Rules:
- Be civil.
- Please start discussions that spark conversation
Other communities
Systems
Functional Programming
Also related
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
It loads immediately (just flat HTML/CSS/image/font files), it does not slow down user experience in the browser, it also signals very clearly there are not weird third-party JS scripts slurping the data for whatever godawful reason.
Additionally, one can build pretty nice, responsive, fast UIs with just HTML and CSS, and browser developers spent decades optimizing their rendering engines for that. JavaScript components on the front-end tend to be buggy, slow, and just all-around shitty UI/UX.
I'd argue that it's not a question of yes or no, but of how much. Personally, I prefer pages that work as expected without enabling them in NoScript too, but that doesn't extend to phones too well imho.
That's because you'll at least have a pretty hard time getting mobile navigation right without JavaScript, at least if you don't want to fall back to odd tree shaped navigation menus which are always visible or something like that. There are CSS hacks for that, but those violate the distinction between content and representation.
Violating the distinction between content and representation in the form of a few hidden radioboxes or checkboxes to be able to make a JS-less menu strikes me as a reasonable trade-off in a lot of cases.
Pretty advanced UIs things can be done using just CSS. For example, this little tidbit of mine. It's not mobile-optimized, but that's beside the point — the point is a complex interface done without a line of JS. Making it mobile-optimized is possible too, of course.
I see your point. On the page that I'm building, the mobile navigation menu is the only usage of Javascript and I think that's reasonable (desktop users are way more likely to disable JS than mobile users, for whom you should optimize anyway in most cases). Of course, there are other use cases where content is really dynamic (e.g. Etherpad), which you just can't tackle with only HTML & CSS.
In my opinion, it's those little things that JS is good at and CSS is (currently) not. JS is a tool, neither more nor less, and like with all tools, it's more important what you do with them than what tool you use.
That's not to say that I'm not in line with you that 95-99% of all JS code in modern web pages is bloat in the best case and acting against the users interest (like by spying on them) in most others, and I'm in no way an apologist for it. Condemning its usage altogether throws the baby out with the bathwater though imho.
Oh, and on performance: JS is pretty optimized today as well. A lot of waiting for modern web pages is due to loading of external resources, which would hardly be any faster if done in C*. In conclusion, we're blaming the language for what people do with it. 😉
* I'm not saying that 3rd party assets are necessary or good, it's just an observation
Sure, I think we basically agree.
There are things that are impossible without JS, and there are things that are possible without it but JS is still the better choice for implementing them — as long as it's not the bloated mess, pulling random libraries from a dozen third party services, that we know and "love" from a lot of websites. And as long as there is graceful degradation built-in.
Absolutely. 🙂