4 ms·
Refreshes can be very fast, and often essentially invisible in modern browsers, when you don't bloat the page unnecessarily, but I think AJAX still has a use fo
by ptx 4y ago
Refreshes can be very fast, and often essentially invisible in modern browsers, when you don't bloat the page unnecessarily, but I think AJAX still has a use for things like the voting button on HN or "add to cart" buttons in a web shop. It would be annoying to lose the scroll position (and perhaps other state) for each item you want to add/upvote.
(Although modern sites that try to sweep latency under the rug by immediately updating the state on the client side and later reverting the change when the server responds are perhaps more annoying.)
- BlueTemplar 4y agoAlso browser refreshes should definitely not lose scroll position, though I can understand how with full ones the former position might not be the "correct" one any more with dynamic content like HN... or substack comments (and how did those manage to be so slow and buggy displaying what is almost exclusively text ?!)
- ptx 4y agoNot a refresh of the same page, but if you perform some action (e.g. adding an item to a shopping card), that would imply a POST request which then (according to the common pattern) redirects to the original page... so then you do lose the original scroll position, I think?
- simonw 4y ago"Refreshes can be very fast, and often essentially invisible in modern browsers" That's thanks to a fantastic browser feature that was introduced a few years ago that hardly anyone knows about: Paint Holding - https://developer.chrome.com/blog/paint-holding/ https://developer.chrome.com/blog/paint-holding/ "... where the browser waits briefly before starting to paint, especially if the page is fast enough. This ensures that the page renders as a whole delivering a truly instant experience." This is why you don't see flashes of a blank white page while a new page is loading on most sites these days.