Skip to content

Commit

Permalink
start watching css right away if startlivecss=true is in the query st…
Browse files Browse the repository at this point in the history
…ring
  • Loading branch information
philc committed Feb 8, 2011
1 parent 3ab0447 commit 504fd23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.markdown
Expand Up @@ -16,6 +16,8 @@ If you want more fine grained control over which CSS is being autoreloaded:
livecss.unwatchAll()
livecss.unwatch(linkElement)

For convenience, livecss will call watchAll() right away if the page has "startlivecss=true" in the URL's query string.

Tips
----
Make sure your server is setting a valid **last-modified** header for its CSS responses. Livecss detects new CSS by frequently making a HEAD request to the URLs referenced in the <link> tags on the page, and it reloads the files which have a recent last-modified header. If your last-modified header is blank or always set to "now", the CSS will continuously reload, once per second. This will put extra load on the browser.
Expand Down
8 changes: 7 additions & 1 deletion livecss.js 100644 → 100755
Expand Up @@ -10,6 +10,9 @@
* livecss.watch(linkElement) - start watching a single <link> element for changes.
* livecss.unwatchAll()
* livecss.unwatch(linkElement)
*
* For convenience, livecss will call watchAll() right away if the page has "startlivecss=true" in the URL's
* query string.
*/
var livecss = {
// How often to poll for changes to the CSS.
Expand Down Expand Up @@ -138,4 +141,7 @@ var livecss = {
var self = this;
return function() { return fn.apply(self, []); };
}
};
};

if (window.location.search.indexOf("startlivecss=true") >= 0)
window.addEventListener("load", function() { livecss.watchAll(); }, false);

0 comments on commit 504fd23

Please sign in to comment.