Sage 9 + Google Fonts

I used to async-load Google Fonts by simply adding the code provided to main.js:

WebFontConfig = {
      google: { families: [ 'Open+Sans:400,400italic,700:latin' ] }
};
(function() {
      var wf = document.createElement('script');
      wf.src = 'https://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);
})();

With Sage-9 I get a bunch of undeclared and unused vars errors. I can bypass those errors by tweaking the .eslintrc file but the fonts and webfont.js won’t load neither. Any ideas?

2 Likes

I’m having the same issue. Any ideas?

Are there problems if you wrap the aforementioned script with eslint-disable/enable instead of tweaking .eslintrc? As in:

/* eslint-disable */
...the script...
/* eslint-enable */

This worked for me:

window.WebFontConfig