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

The Archive Base Latest Questions

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

I using a nice trick to check if an async loaded javascript file with

  • 0

I using a nice trick to check if an async loaded javascript file with a function myFunction exists. The trick is a closure using arguments.callee:

(function() {
  if(typeof myFunction === "undefined") {
    console.log("not loaded");
    setTimeout(arguments.callee, 100);
  } else {
    console.log("loaded");
  }
})();

Is this the best way of doing this though? Is there any issue with browser compatibility using arguments.callee?

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-18T05:24:08+00:00Added an answer on June 18, 2026 at 5:24 am

    First off, you should not poll for the presence of a function. If possible, you should monitor for an event that is triggered when the script is loaded. See this article for how to monitor for the loading of dynamically loaded scripts and you can easily find other examples via Google.

    If the script is loaded via a <script> tag and it’s not async or defer then it will be loaded sychronously so that any code after will be safe to access that script.


    While it would be better to use the actual event that is triggered when the script is loaded (and that’s really what you should figure out how to do), you can wean your technique from arguments.callee like this:

    (function() {
      function check() {
        if(typeof myFunction === "undefined") {
          console.log("not loaded");
          setTimeout(check, 100);
        } else {
          console.log("loaded");
        }
      }
      check();
    })();
    

    A good reason to stop using arguments.callee is that it is not present in ECMA5 strict mode.


    If you care to provide some context for how the script with this function in it is being loaded, then we might be able to provide you some options for better ways to know when it’s loaded because polling for it is certainly not the best way.

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

Sidebar

Related Questions

Using XSL 1.0, I found a nice tokenize function. Now I need to for-each
I am using nice little piece of xstream to perform serialization. I have the
I've been using a nice, elegant plugin called DropKick for my webapp http://jamielottering.github.com/DropKick/ ,
I'm using the very nice PhotoSlider script from http://opiefoto.com/articles/photoslider to create a slide show
So I rewrote my paths to something like: URL/really/nice/paths/ using mod_rewrite rules like this:
Using Deepzoom Composer creates a nice ClientBin and a nice HTML page that works
I am using the jQuery flexigrid plugin (very nice). I've gotten most things working
Well I found a nice tutorial about how to program applications using Bonjour. It's
I'm a developer on nice space MMO using Flash. On new PCs performance is
Maven Jetty plugin is very nice (I'm using version 6.1.26). The only annoying thing

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.