Last active
September 12, 2017 19:05
-
-
Save nolanlawson/a5dc79bdb278b4d6c08ab4b1af624b93 to your computer and use it in GitHub Desktop.
Formatting test 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<link rel="stylesheet" href="style.css"> | |
</head> | |
<body> | |
<h1>Formatting test 1 (nonexistent class)</h1> | |
<div style="padding: 10px;"> | |
<button type="button" id="theButton">Go!</button> | |
</div> | |
<div style="padding: 10px;"> | |
<pre id="theDisplay">Total:</pre> | |
</div> | |
<div id="container" tabindex="0"> | |
<script src="script.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
let $ = document.querySelector.bind(document) | |
let theContainer = $('#container') | |
let theButton = $('#theButton') | |
let theDisplay = $('#theDisplay') | |
let tableHTML = '' | |
for (let i = 0; i < 50; i++) { | |
tableHTML += '<div class = "row">' | |
for (let j = 0; j < 10; j++) { | |
tableHTML += '<div class = "column">' | |
for (let k = 0; k < 500; k++) { | |
tableHTML += '<div class = "cell"></div>' | |
} | |
tableHTML += '</div>' | |
} | |
tableHTML += '</div>' | |
} | |
theContainer.innerHTML = tableHTML | |
let height = theContainer.offsetHeight; | |
let count = 0 | |
theButton.addEventListener('click', () => { | |
requestAnimationFrame(() => { | |
height = theContainer.offsetHeight; | |
theDisplay.innerText = 'Total:' | |
requestAnimationFrame(() => { | |
performance.mark('start') | |
theContainer.classList.add('nonexistent-class') | |
height = theContainer.offsetHeight; | |
performance.mark('end') | |
performance.measure(`total_${++count}`, 'start', 'end') | |
theContainer.classList.remove('nonexistent-class') | |
theDisplay.innerText = `Total: ${performance.getEntriesByName(`total_${count}`).slice(-1)[0].duration}ms` | |
}) | |
}) | |
}) | |
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 0 auto; | |
padding: 10px; | |
max-width: 600px; | |
} | |
.bg-blue { | |
background-color: royalblue; | |
} | |
.bg-red { | |
background-color: crimson; | |
} | |
.column { | |
display: inline-block; | |
background: gray; | |
} | |
.row { | |
background: darkgray; | |
} | |
.cell { | |
display: inline-block; | |
background: blue; | |
width: 1px; | |
height: 1px; | |
margin-right: 1px; | |
vertical-align: top; | |
} | |
pre { | |
font-size: 32px; | |
} | |
button { | |
font-size: 18px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment