This page loaded in X seconds

March 27th, 2018. Tagged: bookmarklets, JavaScript, performance

I was just admiring Tim Kadlec eye-pleasing site. Nice, simple, see what I'm talkin' 'bout.

The feature I liked most was the footer that said "This page loaded in 0.186 seconds". First of all - fast! Second - I thought all sites should have that. And what better way than an on-demand bookmarklet you carry yourself in your daily browsing?

So any time you say to yourself "wow, that was painfully slow" or "weee, my hat flew off!", you can answer the simple question of how long it actually took. Cause perceptions lie.

Anyway, here's the simple code lifted and modified from Tim's:

(function(){
  const t = window.performance && performance.timing;
  if (!t) {
    return;
  }
  const loadTime = (t.loadEventEnd - t.navigationStart) / 1000;
  alert(`This page loaded in ${loadTime} seconds`);
}())

And here's the bookmarklet form - click to try and then just drag to your bookmarks.

load time

Enjoy and let's make the web faster!

Tell your friends about this post on Facebook and Twitter

Sorry, comments disabled and hidden due to excessive spam.

Meanwhile, hit me up on twitter @stoyanstefanov