Created
June 23, 2018 00:34
-
-
Save jlengstorf/4b39f2e5442620f1d26c14d48b580684 to your computer and use it in GitHub Desktop.
Load third-party CSS in a non-blocking way.
This file contains hidden or 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
<html> | |
<head> | |
<!-- head content --> | |
</head> | |
<body> | |
<!-- body content --> | |
<script type="text/javascript"> | |
(function() { | |
// TODO replace this with the third-party CSS to load. | |
const path = 'https://example.org/styles.css'; | |
// Create a link element that loads our third-party CSS. | |
const link = document.createElement('link'); | |
link.setAttribute('rel', 'stylesheet'); | |
link.setAttribute('type', 'text/css'); | |
link.setAttribute('href', path); | |
// Add the new link to the <head>. | |
document.querySelector('head').appendChild(link); | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment