If you want to use API maps without additional <script> elements in the document, the answer is explicit: No the maps API not only used 1 script, it will introduce more scripts into the document.
But when the question is related to the number of scenarios that you must include manually, the answer is yes.
It is possible to load API cards with a callback asynchronously, the workflow will be as follows:
- Download the API asynchronously .
- create a function (the function that you defined as a callback in step # 1)
- Inside the callback:
- initialize GMaps
- run instructions that create a map through GMaps
window.addEventListener('load',function(){ var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://maps.googleapis.com/maps/api/js?v=3&callback=initGmaps'; document.body.appendChild(script); }); function initGmaps(){
Demo: http://jsfiddle.net/doktormolle/cr1w32qn/
source share