Skip to content
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

The analytics.js script doesn't load offline #40

Closed
philipwalton opened this issue Aug 16, 2016 · 3 comments
Closed

The analytics.js script doesn't load offline #40

philipwalton opened this issue Aug 16, 2016 · 3 comments
Labels
Bug An issue with our existing, production codebase.

Comments

@philipwalton
Copy link
Member

Library Affected:
sw-google-offline-analytics

This library currently stores the analytics.js script in cache, but due to CORS restrictions, the script fails to load for offline requests (except in cases where it's already in the browser's HTTP cache).

A short term fix is to have users host the analytics.js script themselves. In the longer term, it'd be nice to either add CORS support to analytics.js or change the way <script> tags handle opaque responses in service worker cache.

I'm looking into the long-term solutions.

@addyosmani addyosmani added the Bug An issue with our existing, production codebase. label Aug 22, 2016
@addyosmani
Copy link
Member

A short term fix is to have users host the analytics.js script themselves.

Are there any gotchas to them self-hosting?

@philipwalton
Copy link
Member Author

No big gotchas; here are the primary downsides I see:

  • When you self-host you don't get updates/bug fixes.
  • When you self-host you miss out on the fact that visitors to your site likely already have the analytics.js script in their cache (since it's used on so many sites on the internet).

@jeffposnick
Copy link
Contributor

On further investigation, it is actually working when served from the cache, as <script> resources don't require CORS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug An issue with our existing, production codebase.
Projects
None yet
Development

No branches or pull requests

3 participants