Skip to content

Instantly share code, notes, and snippets.

@awalterschulze
Created August 22, 2016 07:19
Show Gist options
  • Save awalterschulze/793d46d6f72cbd69c11740a9c6762832 to your computer and use it in GitHub Desktop.
Save awalterschulze/793d46d6f72cbd69c11740a9c6762832 to your computer and use it in GitHub Desktop.
benchmark html page render - javascript
var start = Date.now();
$.ajax({
method: 'GET',
url: 'someurl'
})
.done(function () {
$someElement.html('<div id="results"></div>');
console.log("done", Date.now() - start);
})
.fail(function () {
$someElement.html('<div id="results"></div>');
console.log("fail", Date.now() - start);
});
function waitForRender() {
if (!$("#results").size()) {
window.requestAnimationFrame(waitForRender);
} else {
console.log("rendered", Date.now() - start);
}
}
waitForRender();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment