Skip to content

Instantly share code, notes, and snippets.

@Javvadilakshman
Created August 11, 2015 09:59
Show Gist options
  • Save Javvadilakshman/7bf69770ff002250bfe2 to your computer and use it in GitHub Desktop.
Save Javvadilakshman/7bf69770ff002250bfe2 to your computer and use it in GitHub Desktop.
//By placeing this javascript interval on your page, it will query a local script which checks the last date modified of the css file, and refreshes it if it changed.
var modTime = 0;
setInterval(function(){
$.post("isModified.php", {"file":"main.css", "time":modTime}, function(rst) {
if (rst.time != modTime) {
modTime = rst.time;
// reload style tag
$("head link[rel='stylesheet']:eq(0)").remove();
$("head").prepend($(document.createElement("link")).attr({
"rel":"stylesheet",
"href":"http://sstatic.net/mso/all.css?v=4372"
})
);
}
});
}, 5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment