Google Font display swap in Autoptimize?

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) :-)

8 thoughts on “Google Font display swap in Autoptimize?

    1. frank Post author

      This advanced stuff Roy, better wait for the next major Autoptimize release which will likely have “font-display” as option for Google Font optimization.

      Reply

Leave a Reply to frank Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.