GoogleWebComponents / google-chart

Google Charts API web components
https://www.webcomponents.org/element/@google-web-components/google-chart/elements/google-chart
Apache License 2.0
358 stars 130 forks source link

Load Google Charts asynchronously #225

Closed rslawik closed 5 years ago

rslawik commented 6 years ago

Move loading Google Charts from a synchronous <script> to a dynamically added one (asynchronous). When this component is converted to ES modules, the synchronous behavior cannot be replicated. Luckily the component has been written in such a way (chart constructors are handled asynchronously) that this change is extremely simple.

rslawik commented 6 years ago

@wesalvaro What do you think about this?

We can merge this into master (Polymer 2 version) - there are no breaking changes. After that conversion to Polymer 3 (i.e. ES modules) should be as easy as running the modulizer (https://polymer-library.polymer-project.org/3.0/docs/upgrade#upgrade-a-project-using-modulizer).

wesalvaro commented 5 years ago

Sorry to be slow, I thought my comments posted automatically.

wesalvaro commented 5 years ago

Hmm... Any idea why this would cause the tests to fail?

rslawik commented 5 years ago

Oh, yes, if (google && ...) throws if google is not defined. Replaced by typeof google !== 'undefined'.

Tested with polymer test.