Created
September 16, 2017 07:56
-
-
Save carlosonweb/aacd6569df0746c9ea40dcdc5cc13a45 to your computer and use it in GitHub Desktop.
Fix Font Awesome Render Blocking Issue on Beaver Builder Theme
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
add_action( 'wp_print_scripts', function(){ | |
wp_dequeue_script( 'font-awesome' ); | |
}); | |
add_action('wp_head', function(){ | |
?> | |
<script id="bblocal-font-awesome" type='text/javascript'> | |
var fontAwesomeURL = <?php echo "'" . FL_THEME_URL . "/css/font-awesome.min.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"; | |
}); | |
} | |
loadCSS( fontAwesomeURL ); | |
</script> | |
<?php | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment