summaryrefslogtreecommitdiffstats
path: root/livereload
diff options
context:
space:
mode:
authorbep <bjorn.erik.pedersen@gmail.com>2014-09-10 12:21:22 +0200
committerspf13 <steve.francia@gmail.com>2014-09-11 16:58:06 -0400
commitdf489b4712dd59b097de0d2fb84cfac7a013f5cd (patch)
treed7cce7093d0cf9aad29ecc0fd3fa796df3a207da /livereload
parent0099b5a3cb922ac3f844b5d9d9f098cd1003b0f5 (diff)
Enable soft livereload of CSS and images
Prior to this commit a dummy JavaScript filename was sent to LiveReload when changing a static file (CSS, image etc.), forcing a full browser reload of the page. This commit fixes this by sending the relative file path of the changed static resource, enabling partial live reloading for CSS- and image-changes. If more than one static file happens to end up in the same changeevent-batch, it will fall back to do a full refresh. To enable this logic, the change events with names ending with ".goutputstream*" is now filtered out as temporary. Changes in dynamic content behaves like before. Issue #490
Diffstat (limited to 'livereload')
-rw-r--r--livereload/livereload.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/livereload/livereload.go b/livereload/livereload.go
index 9fb24696d..29a6168a5 100644
--- a/livereload/livereload.go
+++ b/livereload/livereload.go
@@ -39,7 +39,12 @@ func Initialize() {
func ForceRefresh() {
// Tell livereload a js file changed to force a hard refresh
- wsHub.broadcast <- []byte(`{"command":"reload","path":"/x.js","originalPath":"","liveCSS":true}`)
+ RefreshPath("/x.js")
+}
+
+func RefreshPath(s string) {
+ // Tell livereload a file has changed - will force a hard refresh if not CSS or an image
+ wsHub.broadcast <- []byte(`{"command":"reload","path":"` + s + "\"" + `,"originalPath":"","liveCSS":true,"liveImg":true}`)
}
func ServeJS(w http.ResponseWriter, r *http.Request) {