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

Preload Fonts: installation subfolder name is stripped from URLs

Open girlie opened this issue 2 years ago • 0 comments

When saving URLs to Preload Fonts, the domain name is stripped automatically -- but in the case of a subdirectory installation, the subfolder name is also being removed, which results in an invalid URL being preloaded on the front end.

  1. Must have WordPress Site URL located in a subfolder, e.g., https://example.com/sub/
  2. Need at least one font URL to test, e.g., https://example.com/sub/wp-content/themes/twentytwenty/assets/fonts/inter/Inter-upright-var.woff2
  3. Add the URL to the Preload Fonts field, then save the change.
  4. See that the subfolder has also been removed from the URL:
Screen Shot 2023-12-02 at 11 12 31 AM
  1. On the front end, the domain will be added back, but not the subfolder:

<link rel="preload" as="font" href="https://example.com/wp-content/themes/twentytwenty/assets/fonts/inter/Inter-upright-var.woff2" crossorigin>

  1. Thus, the font's URL is invalid and it cannot actually be preloaded.

Related: https://secure.helpscout.net/conversation/2438758491/461019/

girlie avatar Dec 04 '23 15:12 girlie