wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

Self-hosted Google Fonts are not preloaded with Remove Unused CSS when the HTTPS protocol is missing

Open johan-las opened this issue 11 months ago • 2 comments

Describe the bug When Google Fonts are included without the HTTPS protocol and the 'Self-host Google Fonts' option is enabled along with the 'Remove Unused CSS' option, the non-self-hosted fonts are preloaded instead.

Here is an example of code that triggers this issue:

<link href="//fonts.googleapis.com/css?family=Lato:100,100italic,300,300italic,400,400italic,700,700italic,900,900italic&amp;subset=latin,latin-ext" rel="stylesheet" type="text/css">

Once we add the HTTPS protocol, self-hosted fonts were preloaded.

To Reproduce Steps to reproduce the behavior:

  1. Add a Google fonts CSS without the HTTPS protocol.
  2. Add a CSS font-family using the Google fonts to an HTML element.
  3. Clear the Used CSS of the testing page.
  4. See the preload fonts, the Google fonts are loaded from https://fonts.gstatic.com

Expected behavior We should preload the Self-hosted fonts.

Screenshots Without the HTTPS protocol:

Image

With the HTTPS protocol:

Image

Additional context

Slack discussion: https://wp-media.slack.com/archives/C07PZNW7BJ5/p1737643980094689 HelpScout ticket: https://secure.helpscout.net/conversation/2823761415/535995?viewId=8127840

johan-las avatar Jan 27 '25 12:01 johan-las

Hello team!

Same situation here, Ticket

Slack discussion: Font https://fonts.googleapis.com/css?family=Akatab%3A400%2C700%7CBayon%3A400%2C700&ver=6.7.2

Is referenced in the HTML Without the HTTPS protocol:

Screenshot: https://jmp.sh/khaxVtct

Self-host Google Fonts not applied.

Adrianadla avatar Feb 27 '25 20:02 Adrianadla

another case: https://secure.helpscout.net/conversation/3112443619/593527?viewId=377611

webtrainingwheels avatar Oct 21 '25 16:10 webtrainingwheels