7

This page loaded in X seconds

 3 years ago
source link: https://www.phpied.com/this-page-loaded-in-x-seconds/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

This page loaded in X seconds

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

x.png

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK