Skip to content

Instantly share code, notes, and snippets.

@AllThingsSmitty
Created April 24, 2016 13:38
Show Gist options
  • Save AllThingsSmitty/716e8b64f04fbf4d21c3c63e54d4a487 to your computer and use it in GitHub Desktop.
Save AllThingsSmitty/716e8b64f04fbf4d21c3c63e54d4a487 to your computer and use it in GitHub Desktop.
Dynamically check if Font Awesome CDN loaded
function css(element, property) {
return window.getComputedStyle(element, null).getPropertyValue(property);
}
window.onload = function () {
var span = document.createElement('span');
span.className = 'fa';
span.style.display = 'none';
document.body.insertBefore(span, document.body.firstChild);
if ((css(span, 'font-family')) !== 'FontAwesome') {
// add a local fallback
}
document.body.removeChild(span);
};
@shramee
Copy link

shramee commented Mar 15, 2018

I guess default should be fine... 😜 Thanks Matt, really nice! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment