Created
January 4, 2020 01:50
-
-
Save rwehresmann/cd2a5b776cc7e502bc23a274835e3463 to your computer and use it in GitHub Desktop.
We can improve the webpage performance only loading the necessary css first (above the fold), and the rest afterwards. That result in the CSSOM finishing its load faster.
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
| <script type="text/javascript"> | |
| const loadStylesheet = src => { | |
| if(document.createStylesheet) | |
| document.createStylesheet(src); | |
| else { | |
| const stylesheet = document.createElement('link'); | |
| stylesheet.href = src; | |
| stylesheet.type = 'text/css'; | |
| stylesheet.rel = 'stylesheet'; | |
| document.getElementsByTagName('head')[0].appendChild(stylesheet); | |
| } | |
| } | |
| window.onload = function() { | |
| loadStylesheet('./style2.css'); | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment