5 ms·
IF you want the page to be interactive without refreshes though, you gotta do something. Unless you are advocating a completely pre-ajax web. https://en.wikip
by basch 4y ago
IF you want the page to be interactive without refreshes though, you gotta do something. Unless you are advocating a completely pre-ajax web.
https://en.wikipedia.org/wiki/Ajax_(programming) https://en.wikipedia.org/wiki/Ajax_(programming)
- JonathanBeuys 4y agoA bit of Ajax here and there is fine. Look at how HN handles it when you upvote/unvote a comment. Look at how old.reddit.com handles it when you click "load more comments" in a long thread.
- basch 4y agoisnt ajax fancy sending html over the wire? or is it just the non fancy way?
- tomjakubowski 4y agoIt's so fancy in fact that it sends xml
- spcebar 4y agoAJAX stands for Asynchronous JavaScript And XML--it was originally designed for asynchronously manipulating XML data using JavaScript because at the time, the future was XML. The act of using JavaScript to send requests is still sometimes referred to as AJAX, despite usually not dealing with XML in any way. The most common use for sending asynchronous requests is making API calls, which today generally return JSON, but you could use AJAX to load HTML and dynamically add it to the page.
- basch 4y agothe person I replied to said "we dont need any of this fancy hotloading" and then gave examples of fancy hotloading, hence me asking, and pointing out the contradiction. Like you said, AJAX isnt limited to XML, and is really just referring to any use of XMLHttpRequest to hotload data whether its XML, JSON etc. I wasnt asking what ajax was. I was asking if it falls into the definition of "fancy." I think my parent proved the opposite point they meant to. old reddit and hn and wp ARE the fancy html over wire sites, and airbnb and reddit are NOT the fancy over wire sites.
- dtech 4y agoAJAX was the original name for doing asynchronous Javascript calls to a server.
- nonethewiser 4y ago> Look at how HN handles it when you upvote/unvote a comment. How?
- IncRnd 4y agoFor me, HN handles votes using deep links, since I have JS disabled.
- BizarreByte 4y agoI’ve never tried it, but my understanding is when JS is disabled HN fires off a GET request (via a link) and returns a 204 to prevent browser navigation, right?
- boredtofears 4y agoInterestingly enough, although javascript gets used, the vote links don't trigger an XHR request - instead the javascript parses the vote URL from the vote button element and then a GET request is made by creating an Image object in JS. You can see votes appear on your network tab under the image tab instead of Fetch/XHR, even though their response return type is text/html -- interesting little hack, although I'm not quite sure why it's done this way instead of fetching since it already requires JS.
- Izkata 4y agoThis is simply how it was done before XMLHttpRequest existed. If it ain't broke don't fix it, I guess.
- deleted 4y ago[deleted]
- IncRnd 4y agoThe vote/downvote buttons do not require JS. You can verify this in the same, under the network tab. There is disallowed JS request, but the vote succeeds independent of the JS not being allowed.
- slotrans 4y agoWhy are refreshes assumed to be bad?
- sharemywin 4y agoif the page is large and you only need to bring back a little data it's probably better to just grab the little data. or upvote so your just sending a little bit of info back to the server.
- ptx 4y agoRefreshes 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.
- sodapopcan 4y ago"HTML over the wire" generally refers to tech like [0] LiveView, [1] Hotwire, [2] LiveView, [3] Blazor, etc. They aren't about about ditching JS and more about not writing your HTML in JS (and yes, SSR). [0] https://github.com/phoenixframework/phoenix_live_view https://github.com/phoenixframework/phoenix_live_view [1] https://hotwired.dev/ https://hotwired.dev/ [2] https://laravel-livewire.com/ https://laravel-livewire.com/ [3] https://dotnet.microsoft.com/en-us/apps/aspnet/web-apps/blazor https://dotnet.microsoft.com/en-us/apps/aspnet/web-apps/blaz...