Live data from Hacker News

Replacing JavaScript with Just HTML

htmhell.dev

101–110 of 296 posts

Re: Replacing JavaScript with Just HTML

#101
post #45

Earlier quoted context omitted.

> The details / summary thing absolutely kills me. There’s basically nothing you can’t do with them. Animating the details element is tricky. By the spec, browsers don’t natively support transitions between display: none and display: block.

That is no longer true! You can do it in CSS with a combination of `@starting-style` and `transition-behavior: allow-discrete`. [1] Another gotcha you'll run into is animating the height. A couple other new features (`interpolate-size: allow-keywords` and `::details-content`) will let you get around that. [2] Modern CSS is awesome. [1] https://developer.chrome.com/blog/entry-exit-animations [2] https://nerdy.dev/open…

I can't see how a bunch of esoteric incantations are better than just some straight-forward easy to understand and follow JavaScript.

Re: Replacing JavaScript with Just HTML

#102

Earlier quoted context omitted.

Tabs, accordion, combobox. There is a whole lot more, these are just the ones I can remember now.

Yeah this is true at this point. A lot of more complex patterns require JS to be accessible to screen readers. We still should do more with HTML and CSS! And reach for leaner solutions than React everywhere. But be careful going for a pure CSS solution for things like tabs if you don’t understand the accessibility requirements. (I wish the HTML spec would move faster on these common patterns!)

> We still should do more with HTML and CSS! And reach for leaner solutions than React everywhere.

It's pretty difficult for anyone to completely understand all the nuances in HTML and CSS. It's a big mess that gets bigger and messier every year.

We should have just given JavaScript even more power over controlling the viewport and leave HTML and CSS for the history books.

Re: Replacing JavaScript with Just HTML

#103

Earlier quoted context omitted.

That is no longer true! You can do it in CSS with a combination of `@starting-style` and `transition-behavior: allow-discrete`. [1] Another gotcha you'll run into is animating the height. A couple other new features (`interpolate-size: allow-keywords` and `::details-content`) will let you get around that. [2] Modern CSS is awesome. [1] https://developer.chrome.com/blog/entry-exit-animations [2] https://nerdy.dev/open…

I can't see how a bunch of esoteric incantations are better than just some straight-forward easy to understand and follow JavaScript.

Because you need 20x the JS to do the same thing and it’s still not hardware accelerated. These new CSS properties are well supported and will only get better.

Re: Replacing JavaScript with Just HTML

#104
post #49

Earlier quoted context omitted.

like what?

Tabs, accordion, combobox. There is a whole lot more, these are just the ones I can remember now.

Accordion behavior is discussed in the article in the "Accordions / Expanding Content Panels" section:

> Use the same name attribute on all related details (like radio buttons) to restrict only one open panel at a time

And tabs can be a -based accordion with some creative CSS to adjust the layout (left as an exercise for the reader, but I could write up an example if that would be helpful!)

Re: Replacing JavaScript with Just HTML

#105
post #24

I didn't know about , but how are you supposed to use it with a non-trivial amount of items in the list? I don't see how this can be a replacement for javascript/XHR based autocomplete.

And even if you allow XHR and add options to a , it still has terrible UX.

Re: Replacing JavaScript with Just HTML

#106
post #55

Plain HTML is very cozy to me - I came of age in that era. Marquee tags 4eva . But as much as I hate to admit it, it is very difficult to build something functional today with plain HTML and no/minimal JS. If you want, say, a model form that manages its children as well, you're basically going to end up with a 2003-era ASP-feeling application with way too many views and forms (as seen on your employer's current HR sy…

> But as much as I hate to admit it, it is very difficult to build something functional today with plain HTML and no/minimal JS. I would certainly agree that using a little JS can get you further than just HTML. But I think that a plain HTML page is far more pleasant to use (and thus, functional) than the JS monstrosities that dominate the Web today. There's a reason people use the NoScript addon: because a whole lot…

> There's a reason people use the NoScript addon

To be snarky, do they? The average user doesn't even know what JS is.

Users want websites that are fast and solve their problems, with a good UI. They don't care how it's made.

Make websites that people enjoy using. A good developer can do that with any set of tools, though a no-JS approach is limited in scope.

Re: Replacing JavaScript with Just HTML

#107
post #87

Gimme a dark/light mode switch. CSS is allowed.

Why would you build a switch instead of relying on the user’s system settings? The only reason I can imagine is that your dark/light mode is not usable/readable so it forces the user to switch

I often use different light/dark settings between apps and my system. Just because I want system UIs to be dark, for example, doesn't mean I want to read long pages of white-on-black prose on your blog.

Re: Replacing JavaScript with Just HTML

#108

The details / summary thing absolutely kills me. There’s basically nothing you can’t do with them. Hiding and replacing markers is easy. But every component library just pretends they don’t exist. It even saves you the effort of all the aria control and expanded tags: these tags don’t need them.

When you search text with ctrl+f it also searches inside details elements and automatically expands them!

Re: Replacing JavaScript with Just HTML

#109
The interesting part here isn’t “no JavaScript”, it’s that HTML already covers more use cases than people remember (forms, dialogs, validation, navigation).

I ran into this repeatedly while writing my book "You Don’t Need JavaScript"[0]: most JS in these cases isn’t adding capability, it’s compensating for forgotten platform features.

[0] https://theosoti.com/you-dont-need-js/

Re: Replacing JavaScript with Just HTML

#110

Most of this is great, except for the input/datalist bits, which are not sufficiently functional to be used in any real scenario. Users expect these interfaces to be tolerant of misspellings, optional sub text under each option, mobile ux niceties, etc -- and so everyone builds this with js...

And styling! The default styling of datalists in most browsers is just ugly.
Post reply on HN