I am trying to remove the "Script as render blocking file" error from Google Pagespeed insight caused by loading a Google web font. The internet tells me to use Web Font Loader to load the fonts async. I placed the following piece of javascript in my footer, the font loads well, but I still get the Render blocking error in my pagespeed insights results.
Note: The Font Render blocking error only shows up at the mobile test, not on desktop.
<script>
WebFontConfig = {
google: {
families: ['Archivo Narrow:300,400,700']
}
};
(function(d) {
var wf = d.createElement('script'), s = d.scripts[0];
wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js';
wf.async = true;
s.parentNode.insertBefore(wf, s);
})(document);
</script>
EDIT:
Tried to add the script before closing body tag will still cause an render blocking file error:
<script>
WebFontConfig = {
google: {
families: ['Archivo Narrow:300,400,700']
}
};
(function(d) {
var wf = d.createElement('script'), s = d.scripts[0];
wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js';
wf.async = true;
document.body.appendChild(wf);
})(document);
</script>