Live data from Hacker News

Replacing JavaScript with Just HTML

htmhell.dev

71–80 of 296 posts

Re: Replacing JavaScript with Just HTML

#71
I’ve tried replacing my modal components with the element, but had to reverse everything due to this issue: https://github.com/whatwg/html/issues/9936

In short: you can’t have an interactive popover (e.g. a toast notification) on top of a dialog modal.

I’d love to use the new native elements but we’re sadly not quite there yet.

Re: Replacing JavaScript with Just HTML

#72
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 of website designers use JS in ways that make the experience a ton worse for the user.

Re: Replacing JavaScript with Just HTML

#73

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.

You can’t force it to be always open on desktop and collapsible on mobile. That was a deal breaker for me.

Re: Replacing JavaScript with Just HTML

#74
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…

@starting-style Has less than 90% browser support making it a non-starter for the time being at least.

Re: Replacing JavaScript with Just HTML

#75
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.

All of those can be done with pure html/css, eg. https://codepen.io/mikestreety/pen/yVNNNm

Re: Replacing JavaScript with Just HTML

#76
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…

It's not an either/or. Modern Javascript is actually really nice to write and use, and you can write it in a tight, minimal way that doesn't bloat the page or slow it down.

Re: Replacing JavaScript with Just HTML

#77
post #69
post #46

Earlier quoted context omitted.

Animating accordions is almost always a bad idea because the content length can make it unbearable. In general I find animations on the web overused and unnecessary

Seriously. As a user I can count on zero hands the number of times I’ve said “Oh great, I’m sure glad this UI is animated!” - and likewise zero times have I missed it when animation isn’t used. Animation is a way to light small units of your users’ precious time on fire, for zero benefit.

[deleted]

Re: Replacing JavaScript with Just HTML

#78
post #62

Earlier quoted context omitted.

I haven't used it in anger myself, but if you know Elixir and Phoenix you might like Gleam, which compiles to Javascript.

I appreciate the helpful reply, but I think this is precisely the kind of indirection I need to avoid. I'm a sucker for elegance. If left entirely to my own devices I'd probably design a language / write a transpiler of my own, and wind up with exceedingly elegant tooling for websites, and no websites. :)

This is why I don't use Typescript or frameworks in my own projects, I just constantly seek the cleanest abstraction and never get anything done. Using a deliberately messy solution is annoying but at least I accomplish stuff.

Re: Replacing JavaScript with Just HTML

#79

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…

@starting-style Has less than 90% browser support making it a non-starter for the time being at least.

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...

Re: Replacing JavaScript with Just HTML

#80
post #67

HTML and JavaScript serve distinct purposes, making better or worse comparisons logically flawed. Complex/interactive web apps requires JavaScript, period. Attempting to build sophisticated apps solely through HTML (looking at you HTMLX) eventually hits a functional ceiling.

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.
Post reply on HN