9

Gostatic got HTML hot reload functionality#

 3 years ago
source link: https://solovyov.net/blog/2020/gostatic-hot-reload/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Gostatic got HTML hot reload functionality#

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)

Mar 2020


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK