Skip to content

Commit

Permalink
fix: add loading=async to maps API url
Browse files Browse the repository at this point in the history
The new parameter loading=async signals to the API that we're not relying on the load-event of the script tag to determine the maps API status and allows the maps API to do some backward-incompatible performance-optimizations.
  • Loading branch information
usefulthink committed Feb 1, 2024
1 parent b6d6ca7 commit cb1336f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/libraries/google-maps-api-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ export class GoogleMapsApiLoader {
urlParams.set(urlParamName, value);
}
urlParams.set('libraries', library);
urlParams.set('loading', 'async');
urlParams.set('callback', '__googleMapsCallback__');

scriptElement.async = true;
scriptElement.src = MAPS_API_BASE_URL + `?` + urlParams.toString();

window.__googleMapsCallback__ = () => {
Expand Down

0 comments on commit cb1336f

Please sign in to comment.