Elektrine lite

← Feed

@alex@social.alexwlchan.net

Post #2901531

2026-05-14 07:57 UTC

Waiting for website changes in the browser: https://alexwlchan.net/2026/livereload-in-browser/ Once my server knows that files have changed, how do I reload open pages in my browser? With HTTP long polling and a dash of JavaScript.

Replies (3)

  • @alex@social.alexwlchan.net One could use a socket for that, however I have no hands on experience with this particular use case.

    Open ##2901532

  • @dokas@mas.to 2026-05-14 15:44

    @alex@social.alexwlchan.net This is great, I love your posts like this!

    Open ##2901533

  • @dionrhys@toot.wales 2026-05-14 18:05

    @alex@social.alexwlchan.net Nice! Long polling for messaging like this has been formalised as Server-side Events for what it's worth - https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events It lets you send various messages (like "reload me please") from the server with a nice event-based client-side API. This is how esbuild's Live Reload functionality works (https://esbuild.github.io/api/#live-reload): ```javascript new EventSource('/esbuild').addEventListener('change', () => location.reload()) ```

    Open ##2901534