Created
May 27, 2013 13:28
-
-
Save davestewart/5657050 to your computer and use it in GitHub Desktop.
jQuery script to defer loading of LiveReload script until the page is ready. Makes for faster initial page load - useful when working with JS templates and SPAs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(function(){ $('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=2" />').appendTo('head'); }); |
Author
Jolly good!
This was more to make my development page loads a little snappier, when testing within a route on a Backbone SPA. Thanks for the comment, and I'll take a look :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Type Gist is succinct but suffers from two (2) handicaps I believe:
Based on your idea (above), I created a reusable $.deferredScript() method that uses jQuery Deferrred/Promises.
https://gist.github.com/ThomasBurleson/5674241
Any script can be easily loaded. Notification handlers are supported with Promises so script chaining is supported.
And the loaded script is immediately removed from the DOM after load and evaluation.