soundswaste
soundswaste

Reputation: 3074

Record time elapsed since page refresh

Is there a way I could record and ouput in console the time elapsed since I hit refresh to a particular jquery action ?

I have this code :

$(document).ready(function(){
    $('.content').load('url.jsp', function(){
        //some code or plugin that changes the layout of loaded content

        $('.content').fadeIn();
    });
});

I want the time taken since refresh till the fadeIn happens.

Upvotes: 0

Views: 262

Answers (1)

Johan
Johan

Reputation: 35194

Use a Date object or console.time if supported in your browser.

console.time('foo');
var d = new Date();

$(document).ready(function(){
    $('.content').load('url.jsp', function(){

        console.timeEnd('foo');
        console.log(new Date.getTime() - d.getTime() + 'ms');

        $('.content').fadeIn();
    });
});

Upvotes: 1

Related Questions