Created
May 1, 2014 00:21
-
-
Save asterick/09762e6a321fa3c93c75 to your computer and use it in GitHub Desktop.
Replace all unrealized ESI's on a page (good for bookmarklets)
This file contains 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
Array.prototype.forEach.call(document.getElementsByTagName("esi:include"),function(e){function r(e){n.after(e);console.log(t,"loaded");sessionStorage[t]=JSON.stringify({ts:+(new Date)+1e3*60*30,value:e})}var t=e.getAttribute("src"),n=$(e);if(sessionStorage[t]){var i=JSON.parse(sessionStorage[t]);if(i.ts>+(new Date)){r(i.value);return}}if(e.getAttribute("processed")){return}e.setAttribute("processed",true);var s=new XMLHttpRequest;s.open("GET",t,true);s.send();console.log("Loading",t);s.onreadystatechange=function(){if(s.readyState!==4){return}r(s.responseText)}}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment