-
Notifications
You must be signed in to change notification settings - Fork 62
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
Lazily load google map API #66
Comments
I just opened PR #67 that adds an 'exclude' option to the addon config that prevents the addon from adding the Google Maps API script to the app's index.html. This would give you the opportunity to handle loading of the Google Maps API on your own terms. |
Hey @mike-north, what do you think about that addition by @steveszc? Does it solve your issue? |
@asennikov - it does, in a sort of DIY sense (the user could explicitly load it before they need it), but an even better solution would be promise-driven, where the script is loaded "just in time" by a service or something. This way, consumers don't need to do any explicit loading, and they don't need to keep track of whether the script has already been loaded or not |
This would also be helpful for localization. User locale preferences are determined after login, which then the API script could be loaded with the appropriate language/region. |
If I set 'exclude' to true how would I go about loading the Google Maps API manually? |
Totally up to you. You could drop a script tag in your index.html, or you could dynamically create a script tag and insert it into the document when a route is visited or a component is rendered. Here's an example of how you could dynamically load it. Worth mentioning that this repo is more or less in maintenance mode. I'd suggest you use https://github.com/sandydoo/ember-google-maps if you have the flexibility to switch. |
In one of my apps, I only need the google maps API on a few pages. It would be great to not pay the overhead of loading the API unless (and until) it's really necessary.
This would entail making a few things "promise aware" because there's the possibility that the
google.*
stuff hasn't been loaded yet, and will need to be fetched "just in time".The text was updated successfully, but these errors were encountered: