Last active
December 4, 2017 07:43
-
-
Save SilentImp/983f4128f6f8a2516ba5a16e035f2cf5 to your computer and use it in GitHub Desktop.
Это сверх-трешевый способ асинхронной загрузки CSS, который Google Page Speed не видит в принципе.
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
function trashCSSLoader(url) { | |
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', url, true); | |
xhr.onload = function (response) {; | |
applyCSS(response.target.responseText); | |
}; | |
xhr.send(); | |
} | |
function applyCSS(css) { | |
var styles = document.createElement('style'); | |
styles.innerHTML = css; | |
document.head.appendChild(styles); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment