I use google maps. To call the API, I use $.getScript and the initMap () function. All this is in a separate js file:
var map; function initMap() { map = new google.maps.Map(document.getElementById('map'), { center: {lat: -34.397, lng: 150.644}, zoom: 8 }); } $.getScript( 'src', function() { ... }); The problem is that when I put it in $(function() {...}); Uncaught error Ob {message: "initMap is not a function", name: "InvalidValueError", can anyone explain how this works?