-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove <link rel="preconnect dns-prefetch" href="https://www.google-analytics.com"> #1741
Comments
|
I would be fine with the format change but not the removal. |
I can open a PR then to remove |
Could you elaborate? I'd be interested in the why. I'm with @coliff's objection on the location – it's basically directly in front of the actual script, so it should make no difference. Did you add this as a recommendation from Lighthouse? |
@squidfunk yes but it should make a difference since the script is loaded with the async keyword. I'm pretty sure I compared the numbers before but I don't have them anymore. |
fair enough - I'm fine to leave |
well preconnect does what dns-prefetch does + more, I only left in dns-prefetch as a fallback |
I know but Google Analytics isn't a high-priority resource - it's not critical to load and display the page, by adding preconnect it can take browser resources away from loading other assets such as Google Fonts or the GitHub API (which the user does see). The difference either way is very small, so I don't really mind... but overall I'd suggest to not use preconnect for a non-critical resource like Google Analytics. |
I missed that it's |
Google Analytics is a non-critical and optional resource. It's loaded asynchronously, and DNS prefetching will save as little as 25-50ms (as I get from the waterfall graphs @coliff posted). Keeping the prefetching hint is a micro-optimization, which seems to have no measurable effect, but may steal resources from the browser for loading other asynchronous requests like Google Fonts or GitHub stars. For this reason, I consider it the safest to remove the We can re-consider integration when the following conditions are met:
If you want to keep the tag, it's very easy to achieve the same with theme extension, by either extending the {% block analytics %}
<link rel="preconnect dns-prefetch" href="https://www.google-analytics.com">
{{ block.super() }}
{% endblock %} |
Fixed in 1df750a. |
Released as part of 5.2.3 |
I checked that...
Description
The theme currently has
<link rel="preconnect dns-prefetch" href="https://www.google-analytics.com">
in the head. The Google Analytics integration follows immediately afterwards so there is no need to preconnect so I think this can be removed. Furthermore, I think Safari does not accept more than one value for link rel so neither would be used.REF: https://web.dev/preconnect-and-dns-prefetch/#resolve-domain-name-early-with-reldns-prefetch
The text was updated successfully, but these errors were encountered: