-
Notifications
You must be signed in to change notification settings - Fork 55
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
Add note to README about using preconnect/preload to improve google page speed #252
Comments
Hey, could you give me an example how you would do this with Google Analytics or link to the page where Google suggests using the prefetch? I'm guessing this should do it: <link rel="prefetch" href="https://cdn.jsdelivr.net/npm/ga-lite@2/dist/ga-lite.min.js" as="script"> |
Here’s the example: https://web.dev/uses-rel-preconnect/ and the current code says to load it like this:
I don’t see how that integrates with the recommended script. |
Great, thank you for the additional information! You're using This page seems to suggest that you use the In your case it seems that you're serving ga-lite from your own domain, so AFAIK this would have very little effect. However the page says that:
In this case we don't have streaming media, and we know what we're fetching, so I think in your case the best solution would be to use: <link rel="preload" href="{{site.url}}/assets/js/ga-lite.min.js" as="script"> |
So I would just put that somewhere else early on the page, I don't need to modify what's already there in the script, correct? I thought preconnect needed to be part of the loading code which is why I was confused. And I should say, thank you for the extensive and prompt replies. |
Yes, very good point. I think you should always put the
Yes, I can see your point of view. Thank you for bringing this up! I'll make sure to add a note about this to the readme a bit later. I'll leave this issue open to remind myself until I do 👍 |
Thank you for reporting! I opened a separate issue for that at #253 |
Google says I should consider adding a prefetch to improve load times for google analytics. I know how to do that if I was just doing an href but this code is more complex. How should I add that when using ga-lite?
The text was updated successfully, but these errors were encountered: