(function() { function loadJQuery() { var startingTime = new Date().getTime(); var script = document.createElement("SCRIPT"); script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'; script.type = 'text/javascript'; script.onload = function() { var $ = window.jQuery; $(function() { var endingTime = new Date().getTime(); var tookTime = endingTime - startingTime; window.alert("jQuery is loaded, after " + tookTime + " milliseconds!, version=" + $.fn.jquery); }); }; document.getElementsByTagName("head")[0].appendChild(script); } if (window.jQuery) { alert("JQuery loaded"); } else { alert("JQuery not loaded"); loadJQuery(); } })();
Check here for JSFiddle
No comments:
Post a Comment