Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
Last active August 29, 2017 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nolanlawson/1dd8f322eace0237ec672b57f2122459 to your computer and use it in GitHub Desktop.
Save nolanlawson/1dd8f322eace0237ec672b57f2122459 to your computer and use it in GitHub Desktop.
Thrash party
<!doctype html>
<head>
<title>Thrash party</title>
<style>
div {
width: 0px;
height: 0px;
background: green;
color: green;
}
</style>
</head>
<body>
<h1>Thrash party</h1>
<button type=button>Run</button>
<div class="target"></div>
<pre></pre>
<script>
(function () {
document.querySelector('button').addEventListener('click', () => {
var start = performance.now()
var div = document.querySelector('.target')
for(var i = 0; i < 5000; i++) {
div.style.height = 0
div.getBoundingClientRect()
}
var end = performance.now();
document.querySelector('pre').innerHTML += (end - start) + '\n'
})
})()
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment