Loading the script async #8

mihaifm opened this Issue Jul 10, 2013 · 0 comments


None yet
1 participant

mihaifm commented Jul 10, 2013

You are suggesting to load the script using document.write, however this is a blocking operation, as described here:


When the server (the Livereload app) is not running, the browser simply waits for the connection to time out before continuing to render the page. This is especially frustrating on mobile, where it seems to take like forever to load a page.

The solution would be to use the async attribute, or to insert the script element dynamically in the DOM, as mentioned in the posts above.

I'm using this snippet:

(function() {
    var l = document.createElement("script");
    l.async = true;
    l.src = 'http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(l, s);


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment