I have a 3rd party advertisement block on my webpage. Using javascript
, how do I measure the total time it takes to load, parse response and render the advertisement block?
I want to send this timing information back to my server to do reports.
I have a 3rd party advertisement block on my webpage. Using javascript
, how do I measure the total time it takes to load, parse response and render the advertisement block?
I want to send this timing information back to my server to do reports.
You cannot rely solely on javascript
to provide you with the solution you are after.
the biggest problem is the the difficulty in programatically figuring out when the events load, parse and render occur. The closest you can come is recording the time between sending the request and then periodically checking for content in the advertisement container.
Now, if you definitely know the exact template of content that the ad provider will return, you will need to use a script that will periodically check if all the items in the template have loaded and thus measure the time.
Another technique is to use Ajax
. If you are able to load the provider's advertisement using ajax
, you could always calculate the time it took using callbacks and then dynamically add the advert into the page. (also see: How to measure time taken by a function to execute)
To go beyond this, you will need the ad provider to provide you with an api
or callbacks
that you could hook into.
I would suggest taking a look at Boomerang as it helps to measure the performance of your website from your end user's point of view. Other than that, you are at the mercy of external tools like: