3 ms·
Let's say you're updating your UI through Ajax requests, something like Laravel Livewire. For example filtering a list. If you do a web request, although is goi
by whoisjuan 6y ago
Let's say you're updating your UI through Ajax requests, something like Laravel Livewire. For example filtering a list. If you do a web request, although is going to be fast that request and the re-rendering could take up to 300ms.
That's very noticeable when you're browsing. It makes the website feel slow. It's very hard to beat that latency if you're going to update everything from the server.
So you really do need JavaScript to create that snappiness. If you're filtering in the browser with the data that you already received, it's going to feel instant.
I purposefully chose the filtering example because it's something that you can do server-side or client-side. But the server side is always going to feel slower if you're sending all the data in each request and simply changing the rendering.
So where do you draw the line? I think you should only let the server re-render the UI if there's new data being queried and sent. I'm of the opinion that JavaScript should only manage the interactivity of what receives and should be fetching very few data.
Of course this only makes sense if you're using something like Laravel or Rails. But even if you are building a SPA and working against a series of endpoints I think you should make an effort to write those endpoints in such way that you're sending as much data as you can in each request and let the client handle it without requesting again just to re-paint the UI.
- 3np 6y agoYou make a good distinction with “can the working set be preloaded or not”. There are still some cases where I don’t think there’s an obvious answer in the general case. Photo gallery? Product list in webshop?
- vbezhenar 6y agoI've yet to encounter client-side filtering. Usually there are many pages of items. Server returns selected page according to filter criteria. Client just does not have all the items, so he'll be able to filter only already visible items which is not useful.