Live data from Hacker News

Replacing JavaScript with Just HTML

htmhell.dev

161–170 of 296 posts

Re: Replacing JavaScript with Just HTML

#161
post #67

Earlier quoted context omitted.

I dont think anyone is arguing Google Earth should be pure HTML. But it is equally false you cant do Gmail with HTML only. There are things that HTML could do, and should be doing, that is not done or not yet possible simply due to hype and trend from browser vendors. We could continue to polish HTML + sprinkle of Javascript to its absolute maximum before hitting JS Apps. Right now this is far from the case.

Gmail with html only would not be a nice experience. Modern gmail is really bloated but it's actually one of the few web apps I have no problems with.

Gmail used to have an html-only version if I remember rightly. Perhaps still does. It was faster and perfectly usable.

Re: Replacing JavaScript with Just HTML

#162

Earlier quoted context omitted.

I’m not sure this is correct. The DOM class HTMLDetailsElement has the `open` property, which you can use to read/write the details element’s state. If you’re using setAttribute/getAttribute just switch to the property. https://developer.mozilla.org/en-US/docs/Web/API/HTMLDetails...

Having to use the property on the element instance, rather than the actual HTML attribute, is exactly the kind of wrapper code I want to avoid if I'm using a built-in.

You need some JS to change an attribute as much as you need JS to change a property. What am I missing?

I hope the command attribute (https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/...) will eventually support this out of the box. In the meanwhile you can write a single custom --toggle command which is generic and works with any toggleable element

Re: Replacing JavaScript with Just HTML

#163

Earlier quoted context omitted.

Don't use it, it totally blows. For another oddity to not use, check out the multiple select: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/... Expecting users to press modifiers when clicking on these is so funny.

> Expecting users to press modifiers when clicking on these is so funny. I mean… 5 year olds can figure out shift-click in Minecraft.

Trying to figure things out in a game is fun! Trying to figure things out on a website is a sign the UI sucks.

Re: Replacing JavaScript with Just HTML

#164

Earlier quoted context omitted.

It'll just degrade gracefully into not animating the element's entry, so unless the animation is somehow crucial you should still be fine to use it. If you really need to detect whether it's supported there are hacky methods: https://www.bram.us/2024/07/11/feature-detect-css-starting-s...

I agree, but must also observe that I have never met a designer who was willing to admit without a knock-down drag-out fight that any animation they put in was not somehow crucial.

The trick is they'll see it working for themselves. :)

Re: Replacing JavaScript with Just HTML

#165

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 a team of browser engineers have already written and reviewed the code to do it for you; and (hopefully) it’ll be performant, properly tested and accessible… ;-D

Re: Replacing JavaScript with Just HTML

#166

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.

One drawback of details was that cmd+f search wouldn't play nicely when the details was closed. But now there's a hidden="until-found" you can put on child content, along with an associated event. So you can open the details when a user searches :) super useful

Re: Replacing JavaScript with Just HTML

#167

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…

You say awesome, I say layers upon layers of opaque incantations I have to remember. Thank god for LLMs.

“Layers upon layers of opaque incantations”

You’ve described software.

Re: Replacing JavaScript with Just HTML

#168
post #128

Earlier quoted context omitted.

they just said "LLMS"!

My point was that js would be vastly more complicated than these html/css "incantations".

Most front end engineers could do it in JS without ever having to look something up. But the CSS to do it is still obscure to most.

Re: Replacing JavaScript with Just HTML

#169

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.

One drawback of details was that cmd+f search wouldn't play nicely when the details was closed. But now there's a hidden="until-found" you can put on child content, along with an associated event. So you can open the details when a user searches :) super useful

You don't need the hidden="until-found" for details/summary, because that has those semantics automatically, but you can use that for other elements that behave similarly (for example tabs, which can't quite correctly be implemented with details/summary, and so needs to be done by hand).

Also I think the event isn't currently emitted consistently on all browsers (and maybe not at all for hidden="until-found"?) so unfortunately you can't quite rely on that yet if you need to sink some JavaScript state to your html. But in general, yeah, this is a really cool feature.

Post reply on HN