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

  • Home
  • SEARCH
  • 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 394441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:21:22+00:00 2026-05-12T16:21:22+00:00

I think it has to be an easy question but I have been searching

  • 0

I think it has to be an easy question but I have been searching around and have not found the answer anywhere.

The think is that I have an html page with some scripts (in the body) like this one:

<script type="text/javascript">grf();</script>

The grf() function is defined in an external .js file.
The question is: is this function executed once the browser has loaded the page AND all of its external js files? Or it can be the case that the function is executed before the .js files are loaded? And if so, how can I prevent this?

  • 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-05-12T16:21:22+00:00Added an answer on May 12, 2026 at 4:21 pm

    To see if a function is defined:

    // functions are defined or undefined just like regular variables
    function myFunc() {
       /*--code here--*/
    }
    
    // So we just need to see if it's defined
    if( myFunc ) {
       /*--do something here--*/
    } else {
       /*--wait, retry or w/e--*/
    }
    

    When an external script is found, the (x)html will not be read further untill the external script is read (and code inside executed if there’s any executable code there).

    So, calling a function in an external file after the external file was ‘included’ cannot generate a function-not-defined error. (However, keep in mind that you WILL get errors if that external function tries to manipulate the DOM or elements that still “don’t exist” in the page.)

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

Sidebar

Related Questions

I think this question has been asked many a times but I've been searching
This is pretty easy question, but I have been unable to find the solution
I know this topic has been discussed but I think it has some differences.
I don't think this question has been asked before. I'm a bit confused on
I know this question has been asked a couple of times, but there's something
I'm sure this is a very obvious question but I'm not getting anywhere with
I know this question has been asked so many times before but I couldn't
This might be too opinionated a question, but looking for help! I have been
I know this question has been asked several times, but I would like to
I think this might be a fairly easy question. I found a lot of

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.