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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:29:24+00:00 2026-06-02T05:29:24+00:00

My objective here is to load scripts asynchronously when the browser supports defer or

  • 0

My objective here is to load scripts asynchronously when the browser supports defer or async.
If the browser supports neither I don’t care about asynchronous loading (not my bad).
I want to make sure that any script is only executed when the prerequisites for it are fulfilled e.g. jQuery loaded.
I want to load my scripts while other scripts are being loaded (only if the browser supports defer or async).

I want to do this using only the browsers’ API. I don’t want the browser to load any reliable (or not) scripts that do that for me no matter how small they are.

This must work with IE8+, Gecko v.1.9.1+ (e.g. firefox 3.5.* or firefox 9.0+), webkit (e.g. chrome), presto (e.g. Opera). For the ones I didn’t mention the version, I mean the latest stable version.

If possible I don’t want any non easy scripts. I just need something simple to do this job. This means:
If possible, I don’t want stuff like AJAX calls or fancy Objects with some methods to do some workarounds like I’ve seen in other pages. Those are to force async loading of the script in browsers that do not support async or defer

I repeat: I don’t need any fancy things to make a script asynchronous. If the browser does not support defer or async I don’t care. I just care is that the script is loaded so that each part is executed after its prerequisites are met and use async or defer if the browser supports it.

  • 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-02T05:29:25+00:00Added an answer on June 2, 2026 at 5:29 am

    First, using a library such as jQuery makes this whole process infinitely easier, and reliable across browsers. It may increase the download size of your pages (by a very small amount) but the speed gained by efficient script loading/executing will nearly always outweigh that.

    Regarding script async and defer attributes:

    1. async="async": on a script tag is not supported at all by IE8/9, script executes immediately (which is ok according to your question).

    2. defer="defer": on a script tag will begin loading after everything in the order the defer scripts appear in the HTML, prior to DOM Ready. BUT, on Firefox, scripts will often execute AFTER dom ready. This difference makes defer unreliable as a means of ensuring that scripts are loaded before executing functions after dom ready.

    General Guidelines when not using jQuery:

    1. If a script has downstream dependancies you have to place it as a standard script tag at the end of the body tag and have your inline tags all execute after document ready. Otherwise there is no guarantee that the script will be executed prior to the execution of the dependencies. Firefox is the main issue here, a “defer” script may not have finished even after DOM ready.

    2. If a script has no downstream dependnacies, then place it at the end of the body tag, and use async=”async” attribute on the script tag. IE will render it immediately and the others will render it when they receive it.

    General Guidelines when using jQuery:

    1. Place only jQuery in your <head>.

    2. Execute all other scripts as $.getScript().

    3. If a script needs to execute ASAP (such as analytics) use a $.getScript at the top of the body (this will be a non-blocking request, but will process as soon as the client receives the file).

    4. If a script can wait till DOM ready, wrap the $.getScript() call in $(function() {});

    5. If a script has many downstream dependancies, have each one register itself to the callback function for a specific script.

      $(function() { 
        $.getScript("script.js", function() {
          for(var i = 0; i < myCallbacks.length;i++) {
            myCallbacks[i]();
          }
        });
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Still learning Objective-C / iPhone SDK here. I think I know why this wasn't
I'm a beginning to iOS development. My objective is to reduce load-time perception during
I am still new in objective-c programming, I got this exception, but I don't
I have a simple question about creating multiple initialisers within an objective-c class. Basically
Can anyone help me with this one? My objective here is to grab some
Here is my code in Objective-C for iOS that I need help converting to
Here is the code from my style.php script The objective: User should be able
Here is what is the official explanation of firstObjectCommonWithArray in Objective C: Returns the
(Note: The code here is Monotouch/C#, however Objective-C Answers are welcome!) Im using AVPlayer
What is the C# .NET Silverlight equivalent of componentsSeparatedByString in Objective-C? Here is how

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.