11 ms·
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.
by wild_egg 27d ago
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 27d agoI 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 27d agoIt still works exceptionally well in 2026 and generally creates better and faster experiences than an SPA with far, far less code.
- culi 27d agoI hate what it does to my back button
- hnal943 27d agoHTMX is the solution
- zarzavat 27d agoSo 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 27d ago> tiny JS libraries that will make <table>s sortable What are some good ones?
- nozzlegear 27d agoTrading one javascript for another?
- account42 26d agoNo to sorting tables where all the data is already available locally.
- hk__2 27d agoYou don’t need an SPA for that; Wikipedia has client-side sorted tables for example.
- xboxnolifes 27d agoI want tables that can be sorted on multiple columns without triggering a page refresh on every click.
- wild_egg 27d agoView Transitions are your friend
- account42 26d agoIt'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 26d agoIt'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.