Support » Plugin: Autoptimize » Preconnect

  • Resolved gb3k

    (@gb3k)


    Hi Frank,
    First of all, many thanks for your plugin! It is a lot of work and knowledge you share with the community.

    Going straight to my question:
    I have installed AO with CriticalCSS plugin and when auditing my website with Google Audits I received this alert.

    Consider adding preconnect or dns-prefetch resource hints to establish early connections to important third-party origins.

    https://www.googletagmanager.com 330 ms
    https://fonts.googleapis.com 340 ms

    So I added them to the Preconnect to 3rd party domains field like this:
    https://fonts.googleapis.com,https://www.googletagmanager.com

    But now I see this alert

    * A preconnect <link> was found for https://fonts.googleapis.com but was not used by the browser. Check that you are using the crossorigin attribute properly.
    * A preconnect <link> was found for https://www.googletagmanager.com but was not used by the browser. Check that you are using the crossorigin attribute properly.

    Is there a way to force the crossorigin attribute?

    Thanks

    • This topic was modified 2 years, 11 months ago by gb3k.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    By default AO only adds crossorigin for https://fonts.gstatic.com as -at least at the time I added that code- crossorigin was only required for domains from which fonts were downloaded, but you can use the autoptimize_extra_filter_preconn_crossorigin-filter (array in, array out) to add domains that need crossorigin yourself with a couple of lines of code.

    hope this helps,
    frank

    Thread Starter gb3k

    (@gb3k)

    Thank you Frank!
    How do I use the filter? in functions.php? Is there any documentation for that?
    Best,
    Gustavo

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    well, you’ll first and foremost have to create the code that hooks into that filter, but once you have that, the safest & easiest way would be to use the code snippets plugin 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Preconnect’ is closed to new replies.