JSFiddle - React, Tailwind, and code Playground
by bnickel
HTML
<meta name="viewport" content="width=device-width"/>
<h1>Average 50 cached reloads of jquery.mobile-1.1.1.min.js</h1>
<pre></pre>
<script id="jquery" src="http://code.jquery.com/jquery-1.8.0.js"></script>
<script id="jquery-mobile" src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>
JavaScript
var loadTime = 0;
var runCount = 0;
function reloadLibrary() {
var $ = window.jQuery;
var $pre = $('pre');
var $body = $('body');
var $script = $('#jquery-mobile');
$.mobile = null;
$.ajaxSetup({
cache: true
});
var startTime = Date.now();
var remaining = 0;
function done() {
loadTime += Date.now() - startTime;
runCount += 1;
$pre.text('Total: ' + loadTime + 'ms\n Runs: ' + runCount + '\nAvg: ' + loadTime / runCount + 'ms');
if (runCount < 50) {
reloadLibrary();
}
}
$.getScript($script.attr('src'), done);
}
reloadLibrary();