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.

Comments

yannickoo created an issue. See original summary.

yannickoo’s picture

Issue summary: View changes
yannickoo’s picture

Status: Active » Needs review
StatusFileSize
new637 bytes
Madhu_Drupal’s picture

The 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_NAME

If 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.prototype

a.dmitriiev’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.