Autoptimize 2.5.1 (out earlier this week) does not have an option to enforce font-display on Google Fonts just yet, but this little code snippet does exactly that;
add_filter('autoptimize_filter_extra_gfont_fontstring','add_display'); function add_display($in) { return $in.'&display=swap'; }
Happy swapping (or fallback-ing or optional-ing) ๐
Sorry but could you explain where to add this? To the critical css or the style.css?
in neither, but in a code snippet using the code snippets plugin ๐
I am not understand the procedure as well. Can you make it elaborate, I am searching for web font develop for increase page speed.
This advanced stuff Roy, better wait for the next major Autoptimize release which will likely have “font-display” as option for Google Font optimization.
Thanks Frank!
Hi Frank,
I think we have to add this code snippet in to the functions.php file of the WordPress theme.
Thanks,
Diana
You can, if you insist. You could also use the code snippets plugin. Or you could download & install the beta of what will become AO 2.6 which has display=swap automatically for CSS-based Google Font optimizations ๐
thank you for the information ๐