Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9222375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:49:27+00:00 2026-06-18T03:49:27+00:00

In an attempt to load google maps asynchronously I took a look at google’s

  • 0

In an attempt to load google maps asynchronously I took a look at google’s async page

Essentially I am looking for an alternative to document.write in the API and according to some users on this google group post Using the async version will handle this scenario.

My question is why would this script:

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=SET_TO_TRUE_OR_FALSE"
type="text/javascript"></script>

Be any different than:

var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=TRUE_OR_FALSE&callback=initialize";
document.body.appendChild(script);

when the first and second both call the same js file which obviously has the document.write within it? Also why would an updated API want to consider using document.write over append if write generally goes against content security policy?

As a little background info I’m experimenting with Google’s packaged apps and their csp doesn’t allow for document.write.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:49:28+00:00Added an answer on June 18, 2026 at 3:49 am

    One of the main advantage of loading scripts (or other resources) asynchronously/dynamically is that it can dramatically speed up your page load times.

    From Google’s Developer best practices:

    https://developers.google.com/speed/docs/best-practices/rtt#PreferAsyncResources

    When a browser parses a traditional script tag, it must wait for the
    script to download, parse, and execute before rendering any HTML that
    comes after it. With an asynchronous script, however, the browser can
    continue parsing and rendering HTML that comes after the async script,
    without waiting for that script to complete. When a script is loaded
    asynchronously, it is fetched as soon as possible, but its execution
    is deferred until the browser’s UI thread is not busy doing something
    else, such as rendering the web page.

    Another trick I use to decide on whether or not to load a script (such as the Google Maps API) asynchronously is, I ask myself, “Is there a chance that the user will not see, benefit or interact with the results of the loaded script?”. If the answer is yes, then I’ll usually tie the loading of the script to some DOM event (such as button click etc).

    In other words, if a user has to click a button on my web page to view my Google Map; why bother loading all that extra script if there’s a chance the user will never even see it? Instead, load the script asynchronously when a button is clicked, and then load my map.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I attempt to load a Google Chart in node.js, nothing happens. I tried
I'm using d3.js with google maps in a vain attempt to visualise wireless coverage.
I'm trying to load images from google maps static images api into flash. When
I have an image that I get and attempt to load into a graphics
The following is my attempt at a prepare statement. It is causing the page
ok, i try to add black google bar to top of facebook page, so
One of our dev team member got an error Attempt to load oracle client
What would be a good way to attempt to load the hosted jQuery at
My train of thought was that a browser wouldn't attempt to load a source
I've recently begun running into problems with javascript when I attempt to load element

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.