Add a Google Fonts in my theme using the library.
mytheme.libraries.yml
base:
version: VERSION
css:
theme:
//fonts.googleapis.com/css?family=Montserrat:400,500,600,700|Work+Sans:400,500,600,700: { type: external }
and when activating the option "Deferred CSS Execution: Use JS to load CSS" in module advagg_mod,
All CSS are loaded asynchronous except that of the Google Fonts.
1. Add any CSS file containing characters such as =,+|.
2. Go page /admin/config/development/performance/advagg/mod
3. Active "Deferred CSS Execution: Use JS to load CSS" and "Use JS to load external CSS"
4. Clear cache
5. Check the HTML of the page, which must generate the following code:
<link rel="stylesheet" media="all" href="//fonts.googleapis.com/css?family=Montserrat:400,500,600,700|Work+Sans:400,500,600,700" as="style" onload="this.rel='stylesheet'">
<noscript><link rel="stylesheet" media="all" href="//fonts.googleapis.com/css?family=Montserrat:400,500,600,700|Work+Sans:400,500,600,700" /></noscript>
Change regular expression and add these characters,
in file advagg_mod/src/Asset/DeferCss.php line 53
$pattern = '/<link rel=["\']stylesheet["\'](.*)(href="[a-zA-Z0-9\/_\.\-\?\:\=\|\,\+]*")(.*)\/\>/';
Active
5.0
Modifier