Skip to content

Instantly share code, notes, and snippets.

@ebidel
Last active January 15, 2018 07:55
Show Gist options
  • Save ebidel/1041c7ac4f6802034d27 to your computer and use it in GitHub Desktop.
Save ebidel/1041c7ac4f6802034d27 to your computer and use it in GitHub Desktop.

Revisions

  1. ebidel revised this gist Nov 29, 2015. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions firstpaint.js
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,21 @@
    (function() {
    'use strict';

    if (chrome.loadTimes) {
    function getFP() {
    // First paint perf.
    if (window.chrome && window.chrome.loadTimes) {
    const getFP = function() {
    let load = chrome.loadTimes();
    let fp = (load.firstPaintTime - load.startLoadTime) * 1000;
    return Math.round(fp);
    }
    };

    window.onload = e => {
    let render = () => {
    let fp = getFP();
    console.log(`${fp} ms`);
    document.title += ' - ' + fp + ' ms fp';
    };
    setTimeout(render, 50); // Wait a tick so we're guaranteed a fp time.
    window.setTimeout(render, 100); // Wait a tick so we're guaranteed a fp time.
    };
    }
    })();
  2. ebidel created this gist Nov 29, 2015.
    19 changes: 19 additions & 0 deletions firstpaint.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    (function() {
    'use strict';

    if (chrome.loadTimes) {
    function getFP() {
    let load = chrome.loadTimes();
    let fp = (load.firstPaintTime - load.startLoadTime) * 1000;
    return Math.round(fp);
    }
    window.onload = e => {
    let render = () => {
    let fp = getFP();
    console.log(`${fp} ms`);
    document.title += ' - ' + fp + ' ms fp';
    };
    setTimeout(render, 50); // Wait a tick so we're guaranteed a fp time.
    };
    }
    })();