It works by injecting a websocket script which listens for file changes. The filechanges are detected using the go fsnotify package, which in turn uses the different OS's equivalent to inotify.<p>I basically got bored with alt-tabbing and refresing when developing 'vanilla-js'. The hot-reload in the modern frameworks are very nice, so figured I'd recreate it.
My only comment is: "be prepared for a cease and desist from the lawyer's for the real WD-40 company" over the name choice.<p>The fact that they make spray lubricants and you have a website re-loader will likely not make any difference to them.
I thought the name was inspired by a cheap, easily available lubricant that comes in handy for every home.<p>I've tried many simple servers for experimenting with simple static websites (HTML, CSS, JS). I'm currently settled on LiveReload[1] and BrowserSync[2]. LiveReload attaches to other tooling and is more straightforward, while Brower-Sync when looking across a few multiple browsers (out of habit). I'm not particularly fond of tooling that attaches to an IDE, but I like more of the ones that I can pipe with arguments. But then again, I do straightforward stuff these days.<p>LiveReload should also be easily attachable to a simple `python -m SimpleHTTPServer 8000`.<p>1. <a href="https://github.com/livereload">https://github.com/livereload</a><p>2. <a href="https://browsersync.io" rel="nofollow">https://browsersync.io</a>
I've settled on devd (modd) for the past few years.
<a href="https://github.com/cortesi/devd">https://github.com/cortesi/devd</a><p>It's a single file go executable.
Supports CORS too.
I use it via direnv & nix-shell.
I am the self-appointed HN sales pitch for <a href="https://github.com/sigoden/dufs">https://github.com/sigoden/dufs</a>, a fileserver including webdav.
Here’s my hot-reload tool <a href="https://github.com/meblum/serv">https://github.com/meblum/serv</a> it reloads html files when any of its dependencies have changed. Written in Go with zero dependencies and requires no config. Uses server-sent-events to notify webpage of updates. Feedback appreciated.
Nice, I've used an editor plugin for this before, but I like that this isn't tied to any specific editor. Actually Hugo also does this, though again that's tied to a framework:<p><a href="https://gohugo.io/getting-started/usage/#livereload" rel="nofollow">https://gohugo.io/getting-started/usage/#livereload</a><p>Also curious about this: <i>"The delta-streamer.js script then checks if the current window origin is the updated file. If so, it reloads the page."</i><p>Does that mean it doesn't auto-refresh if dependencies (scripts, stylesheets, etc) are updated? Maybe there's room for improvement here though I'm not sure how I would approach it. Maybe just an option to skip the check would do the job.
This is pretty cool. I have two questions, regarding the mirroring:<p>1. For the mirroring, are you using something like rsync (with modifications for the web socket script injection) underneath? Also, will the mirroring reflect destructive changes (like rsync's --delete flag), like if a directory or file is deleted in the original content directory?<p>2. Could you avoid mirroring the content directory, and just directly serve the original content directory, by just simply on-the-fly injecting the relevant script tag in text/html files? (Or, only mirroring those text/html files, and serving the remaining files from the original content directory.)
Should W3C work on a way to do socket connections without JS? It is not high on the list but is popular enough. Things that are more important to be done without JS are horizontal scrolling of items (marquee on steroids?) and slideshows,
between this and liveview... and the infinity websites doing timed or pull-check reloads...<p>is this the best the web have to offer in terms of standards to keep one tab with fresh content? i recall some push standard discussions
Here's literally the same link to a repo from the author from two days ago<p><a href="https://news.ycombinator.com/item?id=41284189">https://news.ycombinator.com/item?id=41284189</a><p>How many times do you feel the need to repeatedly hype this?
I really don't know how you didn't think of the "dodging potential lawsuit" before posting it here, I mean, you didn't know that using actual product names is wrong? It's a shame though, I liked the word play.