• Autoptimize doesn’t really know how to handle this kind of URL when trying to preload it:
    https://fonts.googleapis.com/css2?family=Merriweather:wght@700;900&family=Lato:ital,wght@0,400;0,700;1,400;1,700&display=swap

    It ends up generating this code in the front-end:

    <link rel="preload" href="'https://fonts.googleapis.com/css2?family=Merriweather:wght@700;900&family=Lato:ital" as="other">
    <link rel="preload" href="wght@0" as="other">
    <link rel="preload" href="400;0" as="other">
    <link rel="preload" href="700;1" as="other">
    <link rel="preload" href="400;1" as="other">
    <link rel="preload" href="700&display=swap'" as="other">

    Since each URL needs to be separated by a comma in the preloaded resources field, that brakes the URL in parts that shouldn’t be. Is there any way around this?

    It would be nice to have the option to choose what those preloaded resources are treated as too ??

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    the “what those preloaded resources are treated as too” is automatic really, but the comma’s indeed are an issue. Maybe try URL-encoding the (part of the querystring that has) comma’s, like this;

    https://fonts.googleapis.com/css2?family=Merriweather%3Awght%40700%3B900%26family%3DLato%3Aital%2Cwght%400%2C400%3B0%2C700%3B1%2C400%3B1%2C700&display=swap

    Thread Starter Rodrigo D’Agostino

    (@dt4ils)

    That was a good idea, mate ??

    The URL was kept in one piece as expected, and hopefully it is working as it should. Now I’m only receiving the following warning:
    <link rel=preload> must have a valid 'as' value

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    right-o, forgot that the automatic AS-detection depends on the file extension and there’s not .css there .. darn!

    let’s try to fake it, try

    
    https://fonts.googleapis.com/css2?family=Merriweather%3Awght%40700%3B900%26family%3DLato%3Aital%2Cwght%400%2C400%3B0%2C700%3B1%2C400%3B1%2C700&display=swap#.css

    that might work .. *grin*

    Thread Starter Rodrigo D’Agostino

    (@dt4ils)

    Nope, sadly that made no difference :S
    For the moment it’ll be all right, but it would be nice to have to possibility to manually choose the as attribute.

    Thanks again, mate ??

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    sure, I’ll have a think about if/ when/ how that could be accomplished ??

    Thread Starter Rodrigo D’Agostino

    (@dt4ils)

    I’ll take a look to the code behind it and see if I can be of any assistance.
    Thanks a lot for your help and your amazing plugin, mate ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Wrong handling of preloaded Google Fonts URL’ is closed to new replies.