Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
Last active June 16, 2022 22:25
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/871eced59d144dbe4bec242c1e45c8f1 to your computer and use it in GitHub Desktop.
Save nolanlawson/871eced59d144dbe4bec242c1e45c8f1 to your computer and use it in GitHub Desktop.
Speculative preparser test
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS preparser: imports</title>
</head>
<body>
<h1>CSS preparser: imports</h1>
<pre id="display"></pre>
<script>
const start = Date.now()
while (Date.now() - start < 2000) {
// block rendering
}
</script>
<style>
@import './one.css';
@import './two.css';
</style>
<div>Hello world</div>
<script>
display.innerHTML = performance
.getEntriesByType('resource')
.map(({ startTime, name }) => `${name.split('/').at(-1)} - startTime: ${startTime}ms`)
.join('\n')
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Preparser tests</title>
</head>
<body>
<h1>Preparser tests</h1>
<ul>
<li>
<a href="./links.html">Links</a>
</li>
<li>
<a href="./imports.html">Imports</a>
</li>
</ul>
</body>
</html>
div {
background: darkorange;
}
div {
color: white;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment