- Notifications
You must be signed in to change notification settings - Fork0
A minimal and scriptable way to refresh a webpage
License
SimonMTS/herl
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A minimal and scriptable way to refresh a webpage.
herl
proxies requests to your website and injects a bit of javascript toallow remote page refreshes. Because it is just an HTTP proxy it is compatiblewith any backend language or framework.
Refreshes can be triggered withherl -n
or by manually POSTing toherl
snotification endpoint. Of course you probably want to automate this byintegrating with your editor or an external file-watcher (the example directoryusesentr for generic on-save reloading).
In the below demo, because the index.html file is changed,entr
callsherl -n
which refreshes the browser, andgo run .
which restarts theapplication. While the application is buildingherl
retries calling theorigin server a few times until a connection can be established, so the browseronly sees one refresh.
- Start a proxy server with
herl -serve -origin https://example.com
. - Open the default proxy server url (
http://127.0.0.1:3030
) in the browser.
This will show the content ofexample.com
. - Run
herl -notify
to refresh the page from the command line.
For all flags see:herl -help
.
"Hot" or "live" reloading, as seen in modern frontend frameworks, can beachieved by combiningherl
with, for example,entr.entr
can be usedto execute a command when files change, seeexample/makefile
for a workingexample.
Using the Go toolchain:go install s14.nl/herl@latest
From the AUR asherl-bin
, so e.g.yay -S herl-bin
Thegithub releases page has downloads in the form of:.deb
,.rpm
, and.apk
packages, and plain binaries.
- templ live-reload,the main inspiration for this project. Because it is built specifically foruse with templ, it is hard (if not impossible) to use on its own. Its scopeis also much bigger than that of
herl
, it also includes thefunctionality ofentr
, for example. - node-livereload, requireschanging your code, or installing a browser extension.
- browser-sync, seemingly works in a similar way to
herl
, but has a lot more features and complexity. Written in node js. entr reload-browser
, doesn't seem to exist anymore, and worked by doingsome x.org magic to refresh browser tabs, if I remember correctly.- aarol/reload, requires changing yourcode, and is mainly intended to be used as a Go middleware.
About
A minimal and scriptable way to refresh a webpage