Skip to content

Instantly share code, notes, and snippets.

@lyrixx
Last active December 17, 2015 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lyrixx/5628635 to your computer and use it in GitHub Desktop.
Save lyrixx/5628635 to your computer and use it in GitHub Desktop.
Assets async
<?php
sleep(10);
header('Content-Type: text/css');
echo 'h1 { color: red; }';
<html>
<head>
<title>Hello</title>
</head>
<body>
<h1>HELLO</h1>
This is shown ASAP
<script>
(function () {
var s = document.createElement('link');
s.rel = 'stylesheet';
s.href = 'css.php';
var x = document.getElementsByTagName('title')[0];
x.parentNode.insertBefore(s, x);
})();
</script>
</body>
</html>
<html>
<head>
<title>Hello</title>
<link rel="stylesheet" href="css.php" />
</head>
<body>
<h1>HELLO</h1>
We have to wait css.php loaded to show this content
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment