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

9 thoughts on “Google Font display swap in Autoptimize?”

    • 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 Comment

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