user3758078
user3758078

Reputation:

Loading Script using $.getScript callback function

I'm loading the Google Maps API using jquery $.getScript like so

$.getScript("https://maps.googleapis.com/maps/api/js?async=2&callback=GMapsInit");

You can see that the URL has the callback function GMapsInit. Does the GMapsInit function get called after the script is loaded and executed, or simply after its loaded and not necessarily executed?

Upvotes: 0

Views: 299

Answers (1)

Elie Faës
Elie Faës

Reputation: 3315

The callback is called when the script is loaded AND executed.

This is why you have to use a callback when you load Google Maps.

Upvotes: 1

Related Questions