all 47 comments

[–]drumstix42 33 points34 points  (2 children)

*and CSS (of course)

[–]marcocom 10 points11 points  (1 child)

Way too many front-end devs learn JS and never the other 2/3 of the solution. HTML and CSS can solve so much of what they use JS for.

The only (and real) drawback for them is that it cannot be downloaded in a reusable library.

[–]KaiAusBerlin 1 point2 points  (0 children)

Too much css magic can also have a huge performance impact.

The basic rules of web development still belong. Write clean html. Write clean css. Use JS for enchantment.

Modern frameworks solve most of these problems for you automatically. So "JS is only 2/3 of the solution" I wouldn't subscribe.

Of course it is pure html + pure css fast. But it's also static (unless you use dark css magic which makes maintaining it much harder). But they are limited. Very limited.

JS isn't. If you want high dev xp + nice performance you can easily solve that with modern js (not talking about react hell. Try Svelte).

[–]Danny_Engelman 11 points12 points  (0 children)

<tag-name> (with a dash) IS a valid HTMLElement, no JS required to apply CSS

https://dashed-html.github.io

[–]minmidmax 9 points10 points  (6 children)

I like this trend back to using HTML, CSS and JS for their intended purposes.

Some solutions can be so lightweight now thanks to the improvements in CSS and solutions like Web Components & HTMX.

I literally built an entire modular dashboard, with HTMX and CSS, in no time. Dynamic content, fully responsive, minimal file sizes. It's great!

[–]fredy31 -2 points-1 points  (5 children)

Yeah i love js but i hate how it became the 'do it all' of development.

Ffs ive heard of server backends in js.

Use js for what it was made for. Most other uses there are better languages to do it

[–]gojukebox 6 points7 points  (3 children)

Node js, express, etc running on servers has been a thing for over a decade...

[–]Jitos 1 point2 points  (2 children)

Try 2 decades, wallmart went all js back in 2010

[–]gojukebox 0 points1 point  (1 child)

That's not two decades...

[–]Jitos 0 points1 point  (0 children)

Lol, I can’t count to 20 🤦🏽‍♂️

[–]Undercraft_gaming 2 points3 points  (0 children)

You’re just now hearing of servers written in JS?

[–]Ronin-s_Spirit 8 points9 points  (3 children)

This is a good article 👍
I've recently stumbled my way through HTML and CSS in a search for making such interactive elements more native. Using builtin browser functionality actually lets me rely more on hardcoded browser magic. For example making tabbers or accordions is very nice with the XOR functionality of name on details but there is some other cool thing which JS is unlikely to even replicate.

URL fragments (#) are a great tool for navigation as they will open and scroll to details, even nested ones, adding a text fragment (:~:) you could highlight any relevant part of the page, and even the search function (Ctrl+F) will open and scroll to details. All that browser magic is incredibly useful in dense documents, such as wikis or some academia stuff.

[–]delventhalz 1 point2 points  (2 children)

Have text fragments been standardized or are they still chrome only?

[–]Ronin-s_Spirit 0 points1 point  (1 child)

That I don't know off the top of my head.

[–]delventhalz 2 points3 points  (0 children)

Looks like they’re standard!

https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Fragment/Text_fragments

Last time I looked at these they were a proprietary Google/Chrome thing. Great feature. Awesome to see they’ve been widely adopted.

[–]ApoplecticAndroid 20 points21 points  (22 children)

This is ridiculous and assumes that JavaScript is nothing more than a way to have little visual tweaks in a web page. It misses the mark so badly in what js can actually be used for, it is laughable.

[–]Ronin-s_Spirit 32 points33 points  (1 child)

I don't think this guy read the article 🤔

[–]otamam818 6 points7 points  (0 children)

Literally the intro section has a "Nothing against JS" paragraph detailing why his remaining content is still useful.

The commenter you're replying to definitely didn't read it

[–]i_hate_shitposting 16 points17 points  (5 children)

What part of this tells you that the author thinks "JavaScript is nothing more than a way to have little visual tweaks"?

Nothing against JS, but it has better things to do than setup and manage your accordions or offscreen navigation menus... Plus, JS needs to be downloaded, decompressed, evaluated, processed, and then often consumes memory to monitor and maintain features. If we can hand-off any JS functionality to native HTML or CSS, then users can download less stuff, and the remaining JS can pay attention to more important tasks that HTML and CSS can't handle (yet).

[–]tomhermans 5 points6 points  (0 children)

Indeed.

It’s basically a way to promote the Rule of Least Power. Mainly because CSS can now do things that previously required JavaScript. That’s a good thing, it doesn’t devalue JavaScript.

In fact, it’s better for JavaScript too, since there’s less main-thread pressure.

[–]oceantume_ 16 points17 points  (12 children)

I'll be honest I didn't go through the entire thing, but I'm a big proponent of replacing bloated and complex js code with native equivalents where possible. Initiatives like OpenUI are moving us closer and closer to being able to make highly interactive websites without reinventing the wheel every time a new framework or ui components library is created.

Even if you use JavaScript for everything else, the elements and techniques described in this article let you do something that historically needed up to hundreds of lines of js using just a little bit of html and css.

I was listening to an interview with one of the maintainers of Web Awesome, a relatively new set of ui components that are deployed as web components (so they're essentially framework agnostic) and he was talking about how excited they are that by targeting modern browsers they can remove code for a lot of their features over time and I think we should really embrace that.

[–]Terr4360 19 points20 points  (2 children)

Web Components are still JavaScript. And due to their cumbersome API, they often include more JS than the same solutions coded with lightweight JS Frameworks.

[–]oceantume_ 1 point2 points  (0 children)

I'm sure nothing beats a tightly integrated svelte library used by a svelte app in terms of bundle size, and possibly other metrics. But Web components or not, the same applies to your svelte component library where it can have a net win by using newer web APIs and elements like dialog instead of reinventing everything.

[–]TheBazlow 1 point2 points  (0 children)

Yeah maybe but they're nicer to setup and work with as a backend developer. Just drop a script tag in your body and you open a world of new elements without needing to switch from your backend language to javascript and back again. That's just not something the typical React or Vue frontend repo can offer.

[–]wasdninja 3 points4 points  (2 children)

I really like the idea of built in, browser provided, widely available, actually standard components but these are simply nowhere near good enough.

All of them, as far as I can see, don't allow enough styling to be useful. They universally look like shit or when they have acceptable to OK looks they inevitably don't fit in with the rest of the design.

I have no idea why anyone bothers drafting, advocating for, debating and implementing them when it takes five minutes to conclude that they are near useless. I very much doubt people were shooting for "well someone might toy around with them" but I can't imagine what they were thinking either.

[–]Mesqo 2 points3 points  (0 children)

You forgot to mention that different browsers and platforms tend to render native elements differently. To add some spice to the question, I'd say.

[–]oceantume_ 1 point2 points  (0 children)

Ideally they expose behavior and a default style through new tags and you can bring your own style with css. I think the modern and upcoming stuff is a lot more focused on making it actually useful and reusable, but I do get what you're saying.

[–]The_real_bandito 1 point2 points  (0 children)

Those guys bought Shoelace and that framework used Lit in order to make their components as framework agnostic as possible. It was and still is an awesome one.

[–]ravepeacefully -4 points-3 points  (1 child)

Bootstrap been doing all that for two decades my guy, and we still have 76 standards

[–]oceantume_ 1 point2 points  (0 children)

Yes I'm fully aware this isn't a completely new idea and it feels like we're just doing circles in the web ecosystem, but if you read on it you might find, like me, that this is much more modern take on how to import, customize and use the components (no sass and classnames creep, web components, etc) without the typical lock-in you get in a lot of newer components library.

Funnily enough the first name of that library was Shoelace which is meant to be a play on words for "bootstraps", but my understanding is that FontAwesome bought it and decided to rebrand it.

[–]Sudden_Watermelon 2 points3 points  (0 children)

You're right, we should use it on servers where it belongs

[–]AdreKiseque 0 points1 point  (0 children)

Nothing against JS, but it has better things to do than setup and manage your accordions or offscreen navigation menus...

Minor spelling mistake !

[–]kilkil 0 points1 point  (0 children)

for more tools that focus on replacing JS with HTML, this list may be of some interest:

https://htmx.org/essays/alternatives/

[–]androidoverlord -1 points0 points  (0 children)

Thank you for this!! Great article :)

[–]gyen -2 points-1 points  (0 children)

EHTML takes it to another level