Hacker News

Favorites Setup
Comment by wild_egg | original | HTML Can Do That
[−]wild_egg · 2026-08-20 Thu 16:33 UTC · link
You want client side table sorting?

It's really easy to do this with server rendered HTML. Put a link with the sort param in the column headers and be done.

[−]mxuribe · 2026-08-20 Thu 16:55 UTC · link
I used to do this in the early 2000s! Some folks back then would ask whether i was afraid that clicking a link (which loads a "new" web page) would slow things down and create an awful experience for users...but, my team and I would really focus on keeping web pages slim/lightweight to begin with...so it rarely was a problem. I don't think we were geniuses or anything like that, but keeping things light (always and from the beginning) enabled us to "cheat" (like this "hack" of the links in the column headers) in ways that were beneficial but with very low risk. Sometimes it took an extra moment or two at the beginning of an effort...but it ALWAYS paid off down the road, and in many different ways.
[−]wild_egg · 2026-08-20 Thu 17:15 UTC · link
It still works exceptionally well in 2026 and generally creates better and faster experiences than an SPA with far, far less code.
[−]culi · 2026-08-20 Thu 17:38 UTC · link
I hate what it does to my back button
[−]hnal943 · 2026-08-20 Thu 17:48 UTC · link
HTMX is the solution
[−]zarzavat · 2026-08-20 Thu 18:36 UTC · link
So instead of using JS to sort the table directly, now you make a JS fetch() request to sort the table?!

It does make sense in one situation, if the table is a large server-side paginated one and the sorting is really an ORDER BY clause. But for a basic table that fits entirely on the client, it doesn't make sense at all. There are tiny JS libraries that will make <table>s sortable when you add a particular class name.

[−]everybodyknows · 2026-08-20 Thu 21:18 UTC · link
> tiny JS libraries that will make <table>s sortable

What are some good ones?

[−]nozzlegear · 2026-08-20 Thu 19:00 UTC · link
Trading one javascript for another?
[−]account42 · 2026-08-21 Fri 12:05 UTC · link
No to sorting tables where all the data is already available locally.
[−]hk__2 · 2026-08-20 Thu 19:44 UTC · link
You don’t need an SPA for that; Wikipedia has client-side sorted tables for example.
[−]xboxnolifes · 2026-08-20 Thu 17:46 UTC · link
I want tables that can be sorted on multiple columns without triggering a page refresh on every click.
[−]wild_egg · 2026-08-20 Thu 19:24 UTC · link
View Transitions are your friend
[−]account42 · 2026-08-21 Fri 12:06 UTC · link
It's a bit annoying when the sorting leaks into URLs people share, a bit like if the scroll position would be automatically included there.
[−]CrimsonRain · 2026-08-21 Fri 13:30 UTC · link
It's not as fast.

It is far more resources hungry when dealing with beyond 50 rows or more.

Puts needless pressure on backend.

It is not a good idea when sending whole dataset to client is feasible/better choice.