Skip to content
Permalink
Browse files

transform/livereloadinject: Add defer to livereload script tag

In #6821 we moved the loading from end of body to head to make Turbolinks and similar work.

This commit adds a defer attribute to avoid page parse blocking.
  • Loading branch information
bep committed Jan 31, 2020
1 parent ef78a0d commit b3f0674b80a32425aeb4412f318c720391bbf773
@@ -59,7 +59,7 @@ func New(port int) transform.Transformer {
return err
}

script := []byte(fmt.Sprintf(`<script src="/livereload.js?port=%d&mindelay=10&v=2" data-no-instant></script>`, port))
script := []byte(fmt.Sprintf(`<script src="/livereload.js?port=%d&mindelay=10&v=2" data-no-instant defer></script>`, port))

i := idx
if match.appendScript {
@@ -25,7 +25,7 @@ import (
func TestLiveReloadInject(t *testing.T) {
c := qt.New(t)

expectBase := `<script src="/livereload.js?port=1313&mindelay=10&v=2" data-no-instant></script>`
expectBase := `<script src="/livereload.js?port=1313&mindelay=10&v=2" data-no-instant defer></script>`
apply := func(s string) string {
out := new(bytes.Buffer)
in := strings.NewReader(s)

0 comments on commit b3f0674

Please sign in to comment.
You can’t perform that action at this time.