Created
June 29, 2018 10:20
-
-
Save oliverturner/bfa2b8eafb2bc78e284ede9c2ed92652 to your computer and use it in GitHub Desktop.
Async CSS loader
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
const loadcss = (href, media = '') => | |
new Promise(r => | |
document.head.appendChild(Object.assign( | |
document.createElement('link'), | |
{ | |
onload() { this.media = media; r() }, | |
rel: 'stylesheet', media: 'only x', href | |
}) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment