Problem/Motivation
When viewing a map there is an error in the console
Google Maps JavaScript API has been loaded directly without a callback. This is not supported and can lead to race conditions and suboptimal performance. For supported loading patterns please see https://goo.gle/js-api-loading
Steps to reproduce
Open a page with a map.
Proposed resolution
Use Function.prototype as callback function as this was recommended here.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | styled-google-map-3378757-empty-callback-3.patch | 637 bytes | yannickoo |
Comments
Comment #2
yannickooComment #3
yannickooComment #4
Madhu_Drupal commentedThe short answer is to specify a callback value. Set the name of the JavaScript function that you would like to trigger once the external API library has finished loading.
https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=FUNCTION_NAMEIf you don't actually have a callback function to run immediately after the library loads, you can use Function.prototype as a noop stand-in.
https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=Function.prototypeComment #6
a.dmitriiev commented