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 9161807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:03:27+00:00 2026-06-17T14:03:27+00:00

I have a javascript tag embedded in the <head> of a webpage. In this

  • 0

I have a javascript tag embedded in the <head> of a webpage. In this script (served via Amazon Cloudfront) it does some processing and then if certain checks are set, appends another script to the document head. Here is an example of that embed:

    var js = document.createElement('script');
    js.src = 'http://cdn.mysite.com/script.js?cache_bust='+Math.random();
    document.getElementsByTagName('head')[0].appendChild(js);

This works properly, however it’s non-blocking meaning the webpage continues to load while that script is being appended to the head.

Is there any way to embed a script in a blocking manner so the webpage “hangs” while the new script is setup?

I was thinking about maybe moving the first script to just below the <body> tag and then using document.write() the second script but I’d prefer to keep it in the <head>.

Any ideas? Thanks!

  • 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-17T14:03:28+00:00Added an answer on June 17, 2026 at 2:03 pm

    You’re right, document.write should work. As Dr.Molle mentioned in the comment, you can use inside the <head> too (the <head> is part of the document too!).

    So:

    <head>
        <script>
        var src = 'http://cdn.mysite.com/script.js?cache_bust='+Math.random();
        document.write '<script src="">'+ src + '</scr' + 'ipt>';
        </script>
    </head>
    

    The '</scr' + 'ipt>' part is a precaution, browsers usually think the outer script block is being closed when they find </script>, even if inside a string.

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

Sidebar

Related Questions

In my main Web Page (Viewer.aspx) I have a javascript script tag like this
I have this code <head> <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"> </script> <script type="text/javascript" src="future_value.js"> </script> <script>
I have some javascript that is embedded in the html file like this <html>
I have some javascript code that creates an img tag with a mouseover callback,
I have javascript code some thing like this -- var count=3; var pl=new Array(count);
I have some javascript that ends up programatically clicking on a button: document.getElementById(myButton).click(); This
I have a javaScript tag: <!-- Begin ParsTools.com Prayer Times Code --> <script type=text/javascript
I have a javascript code that have span tag and inside the span tag
I have a javascript function that changes the innerHtml of a <div> tag to
Ok, i have a javascript function which toggles the innerhtml of a div tag

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.