Created
June 22, 2016 10:04
-
-
Save itamar/71e16c5c0c9b8081dfc62bd80ea5b4ac to your computer and use it in GitHub Desktop.
LoadCSS.js
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
| // http://www.gotknowhow.com/articles/how-to-asynchronously-load-font-awesome-css-file | |
| <script> | |
| // Asynchronously load non-critical css | |
| function loadCSS(e, t, n) { "use strict"; var i = window.document.createElement("link"); var o = t || window.document.getElementsByTagName("script")[0]; i.rel = "stylesheet"; i.href = e; i.media = "only x"; o.parentNode.insertBefore(i, o); setTimeout(function () { i.media = n || "all" }) } | |
| // load css file async | |
| loadCSS("//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css"); | |
| </script> | |
| // load css file async | |
| loadCSS("/css/my-test.css"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment