Google Maps JavaScript API has been loaded directly without a callback

I see Google recommendation for Google Maps JavaScript API has been loaded directly without a callback:
*The bootstrap loader is the recommended way to load the Maps JavaScript API. The JS API loader is also provided as an alternative. We recommend that you review both approaches, and choose the one that is most appropriate for how the code in your project is structured.

  (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
    key: "YOUR_API_KEY",
    v: "weekly",
    // Use the 'v' parameter to indicate the version to use (weekly, beta, alpha, etc.).
    // Add other bootstrap parameters as needed, using camel case.

How to transform usual an old code and async defer and v value in the production:

<script type="text/javascript" src="" async defer id=""></script>
<script src=""></script>

Just replace YOUR_API_KEY with your actual API key. This should get rid of the error message.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.