solovyov.net

Gostatic got HTML hot reload functionality

1 min read · software, gostatic

After years of reminding myself to do it, I finally did it: gostatic now got hot reload! And it took me only two month (nothing compared to years of wait) to make a release and write this post.

I should say, it’s pretty nifty, seeing browser being updated almost immediately after pressing save (should I enable autosave in Emacs?). It’s not a so-called “Live Reload”, when a page is reloaded, that is a literal update-on-the-fly. Just look at it yourself:

That’s it, I gave you a reason to finally go and experiment with gostatic, if you never did. :)

So how does it work? A script is inserted before closing </head>, and this script establishes WebSocket connection. Then when some file changes server’s watching mechanism sends a command down this connection: page, if HTML changes, and css, if it’s the CSS. Simple and robust (I hope).

All in all just a really useful feature, and a pleasant to use and see. Enjoy. (I said that to myself)

If you like what you read — subscribe to my Twitter, I always post links to new posts there. Or, in case you're an old school person longing for an ancient technology, put a link to my RSS feed in your feed reader (it's actually Atom feed, but who cares).

Other recent posts

Server-Sent Events, but with POST
ngrok for the wicked, or expose your ports comfortably
PostgreSQL collation
History Snapshotting in TwinSpark
Code streaming: hundred ounces of nuances