Live data from Hacker News

Replacing JavaScript with Just HTML

htmhell.dev

201–210 of 296 posts

Re: Replacing JavaScript with Just HTML

#201

Earlier quoted context omitted.

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.

Of course you can, but most people still opt to pull in a whole framework (React) or heavy library (jQuery) just to achieve what's essentially a few XMLHttpRequests and some DOM changes.

Maybe because it is easier to track one library, react and jsx. I wouldn't use xmlhttprequest since the request api exist.

Re: Replacing JavaScript with Just HTML

#202
post #169

Earlier quoted context omitted.

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 unf…

Oh huh I didn't know details supported that naturally. I'm guessing this wasn't always the case and my knowledge is simply outdated. TIL!

Yeah, support was patchy until recently (and I think that behaviour might not even have been standardised?) so I think a lot of people have assumed that if you want that functionality you need to do something extra.

Re: Replacing JavaScript with Just HTML

#203
post #145

Just been through several frontend interviews in the last few months, where it's clear that they still judge a developer's JS skills (especially React) than being semantically correct on HTML elements. Every question/exercise is centred around how well you know React hooks, effect, memoization, modern css-in-js etc. Given I've been working with Astro recently, in one interview I talked about DOM APIs and I can see th…

Remember that a large part of hiring is finding someone who fits in an existing team. A team that uses react won't appreciate someone choosing to use native DOM APIs instead of a react component.

In every React team I've been part of we've wanted to use as little react as possible and use native DOM apis when possible. React would be used purely for state management or interactivity.

I feel like teams that have used react enough learn that the less React you can use the better :) it's a great tool, but most teams use it because it's all they know and they don't know what they don't know about html.

Re: Replacing JavaScript with Just HTML

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

I miss marquee... I burned more tokens than I'd like to admit to build a marquee-like feature in react and it was really just the same text twice with an animation that hopefully no one notices isn't a clean loop on some viewport sizes (since it restarts after reaching the end).

Re: Replacing JavaScript with Just HTML

#205
The and elements are great, but I think the bigger missed opportunity is the lack of inline examples/demos on the page itself. Would be much more powerful to actually show these working rather than linking to external codepens.

A few thoughts on the practicality:

1. Progressive enhancement is the real win here, not "replacing" JavaScript. These HTML features provide a baseline that works without JS, then you enhance with JS for better UX (animations, state persistence, etc.)

2. The details/summary approach breaks down when you need: - Custom animations/transitions - State synchronization across multiple elements - Analytics tracking on user interactions - Keyboard shortcuts beyond basic tab navigation

3. What about the element? That's another underutilized HTML feature that could replace a ton of modal/popup JavaScript.

4. Have you explored the Popover API? It's getting broader browser support and handles a lot of common UI patterns without JS.

The spirit of "use the platform" is great, but the title feels a bit clickbaity - you're not really replacing JS, just avoiding it where unnecessary. Which is good practice anyway!

Re: Replacing JavaScript with Just HTML

#206

Earlier quoted context omitted.

Until your client tells you that it doesn't work in Edge and you find out it's because every browser has its own styling and they are impossible to change enough to get the really long options to show up correctly. Then you're stuck with a bugfix's allotment of time to implement an accessible, correctly themed combo box that you should have reached for in the first place, just like what you had to do last week with t…

Right, don't add complexity until you have to.

I'd argue that adding complexity from the get-go to ensure that all users have a pleasant experience from the get-go is better than simplicity at the expense of some percentage of users.

I think it's important for web devs to spend more than two seconds to think if the complexity is necessary from the get-go though.

Re: Replacing JavaScript with Just HTML

#207

A missed opportunity to not have all of these examples inline. The page/blog-post would be so much more convincing if it utilized all of these HTML replacements instead (or in addition) to linking to codepen.

I had assumed this was a 25 year old article at first glance. Those dithered gifs sure are a throwback!

Re: Replacing JavaScript with Just HTML

#208
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

#209
post #202

Earlier quoted context omitted.

Oh huh I didn't know details supported that naturally. I'm guessing this wasn't always the case and my knowledge is simply outdated. TIL!

Yeah, support was patchy until recently (and I think that behaviour might not even have been standardised?) so I think a lot of people have assumed that if you want that functionality you need to do something extra.

Yes, Google started revealing the contents of a few years ago, long after the element was supported in all browsers. Firefox added support earlier this year and Safari just added it.

Supporting the behavior was related to changing the user agent CSS when they're closed and the other browsers implemented it and hidden=until-found at the same time.

https://caniuse.com/mdn-html_elements_details_search_match_o...

Re: Replacing JavaScript with Just HTML

#210

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.

I'm not particularly familiar with modern webdev, can anyone share a minimal example?
Post reply on HN