GoogleWebComponents / google-apis

Web components for loading Google's JavaScript Libraries
https://elements.polymer-project.org/elements/google-apis
Other
87 stars 64 forks source link

Load all Maps API libraries by default (proposal) #57

Closed brendankenny closed 8 years ago

brendankenny commented 8 years ago

Due to the way the Maps API loads libraries (designed in the ancient days of ~2008) you have to load all the libraries you'll need on first load and can't load more libraries later. You also need to make sure the API is only loaded once on each page.

The second problem is taken care of by <google-maps-api> but the first means that every other element that uses it needs to specify the same set of libraries as the rest for them to work on the same page together. This can be problematic if you're trying to make a SPA and have a need for different libraries in different parts of your app, or if you don't even realize an element you're using contains a <google-maps-api> and so needs a libraries property properly set. We leave it up to the end developer to coordinate this (see e.g. https://github.com/GoogleWebComponents/google-streetview-pano/issues/15). Once you know the problem exists, it's easy to diagnose and fix, but it's annoying.

To eliminate these problems, I propose we always load all four libraries whenever the Maps API is loaded and eliminate the libraries property on all google-map-* elements. Configuration gets simpler, you don't have to repeat yourself over and over to use the exact same libraries you already loaded, and we eliminate a class of bugs. Boom.

Downsides:

Why the downsides aren't so bad:

Any possible network performance problem should be fixed at the browser/Maps API/serving infrastructure levels anyways. We shouldn't burden all the google-map-* components with this additional API complexity.

brendankenny commented 8 years ago

(this should maybe be merged into #22, but the suggestion there will not work because of the temporal aspect of the problem: the only union of libraries that will include all possible libraries needed by elements that could be added to the page in the future is the set of all libraries :)

ebidel commented 8 years ago

Want to close and dump https://github.com/GoogleWebComponents/google-apis/issues/57#issue-109014729 into #22?