Skip to content

Instantly share code, notes, and snippets.

@fzaninotto
Forked from lyrixx/css.php
Created May 22, 2013 20:54
Show Gist options
  • Save fzaninotto/5630818 to your computer and use it in GitHub Desktop.
Save fzaninotto/5630818 to your computer and use it in GitHub Desktop.
<?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>
</head>
<body>
<link rel="stylesheet" href="css.php" />
<h1>HELLO</h1>
This is shown ASAP
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment