Skip to content

Instantly share code, notes, and snippets.

@kosmiq
Forked from thomasmb/gist:b67680a04ae75bc301b7
Last active October 17, 2017 11:34
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save kosmiq/2cdac1677d0ba07fc846 to your computer and use it in GitHub Desktop.
Save kosmiq/2cdac1677d0ba07fc846 to your computer and use it in GitHub Desktop.
An updated version of Thomas Bensmanns Load Google Fonts via JS (https://bensmann.no/google-webfonts-performance/) with a SHIM for IE9 and IE8.
WebFontConfig = {
google: { families: [ \'Ek+Mukta:200,800:latin\' ] }
};
var cb = function() {
var wf = document.createElement(\'script\');
wf.src = \'//ajax.googleapis.com/ajax/libs/webfont/1/webfont.js\';
wf.type = \'text/javascript\';
wf.async = \'true\';
var s = document.getElementsByTagName(\'script\')[0];
s.parentNode.insertBefore(wf, s);
};
// shim layer with setTimeout fallback. Thanks Paul Irish http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
function( callback ){
window.setTimeout(callback, 1000 / 60);
};
})();
//Remove the old raf var and set it with our SHIM instead.
//var raf = requestAnimationFrame || mozRequestAnimationFrame || webkitRequestAnimationFrame || msRequestAnimationFrame;
var raf = requestAnimFrame;
if(raf){
raf(cb);
}else{
window.addEventListener(\'load\', cb);
}
@vaidyz13
Copy link

Hey guys,

Help me please with this issue. As I'm new with creating websites - i don't know what file should be edited to get results with suggested code. And where I could locate via Cpanel?

Thanks in advance.

Vaidotas

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