Skip to content

Instantly share code, notes, and snippets.

@tkadlec
Created April 23, 2015 11:54
Show Gist options
  • Save tkadlec/7e352b74b1961a3e36d7 to your computer and use it in GitHub Desktop.
Save tkadlec/7e352b74b1961a3e36d7 to your computer and use it in GitHub Desktop.

Revisions

  1. tkadlec renamed this gist Apr 23, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. tkadlec created this gist Apr 23, 2015.
    35 changes: 35 additions & 0 deletions perf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    (function () {
    var perfBar = function(budget) {

    window.onload = function() {
    window.performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {};


    var timing = window.performance.timing,
    now = new Date().getTime(),
    output, loadTime;

    if (!timing) {
    //fail silently
    return;
    }
    budget = budget ? budget : 1000;
    var start = timing.navigationStart;

    var results = document.createElement('div');
    results.setAttribute('id', 'results');
    loadTime = now - start;
    results.innerHTML = (now - start) + "ms";
    if (loadTime > budget) {
    results.className += ' overBudget';
    } else {
    results.className += ' underBudget';
    }
    document.body.appendChild(results);
    }

    };
    window.perfBar = perfBar;

    }());