Skip to content

Instantly share code, notes, and snippets.

@peteee
Created April 23, 2021 17:01
Show Gist options
  • Save peteee/438488dffade8b4743300eace9f73073 to your computer and use it in GitHub Desktop.
Save peteee/438488dffade8b4743300eace9f73073 to your computer and use it in GitHub Desktop.
Force reload of JS every second (jQuery)
jQuery(document).ready(function() {
function checkTime(i) {
return (i < 10) ? "0" + i : i;
}
var today = new Date(),
h = checkTime(today.getHours()),
m = checkTime(today.getMinutes()),
s = checkTime(today.getSeconds());
jQuery('body').append('<script id="data-src" src="https://MYDOMAIN.com/js/MYSCRIPT.js?v='+h+m+s+'"><\/script>');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment