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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:43:32+00:00 2026-05-23T06:43:32+00:00

I have a question on jQuery $(document).ready Let’s say we have a HTML page

  • 0

I have a question on jQuery $(document).ready

Let’s say we have a HTML page which includes 2 JavaScript files

<script language="javascript" src="script1.js" ></script>
<script language="javascript" src="script2.js" ></script>

Now let’s say in both these script files, we have $(document) as follows

Inside script1.js:

$(document).ready(function(){
    globalVar = 1;
})

Inside script2.js:

$(document).ready(function(){
    globalVar = 2;
})

Now my Questions are:

  1. Will both these ready event function get fired ?
  2. If yes, what will the order in which they get fired, since the
    document will be ready at the same
    time for both of them?
  3. Is this approach recommended OR we should ideally have only 1
    $(document).ready ?
  4. Is the order of execution same across all the browsers (IE,FF,etc)?

Thank you.

  • 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-23T06:43:33+00:00Added an answer on May 23, 2026 at 6:43 am
    1. Will both these ready event function get fired ?

    Yes, they will both get fired.

    1. what will the order in which they get fired, since the document will be ready at the same time for both of them?

    In the way they appear (top to bottom), because the ready event will be fired once, and all the event listeners will get notified one after another.

    1. Is this approach recommended OR we should ideally have only 1 $(document).ready ?

    It is OK to do it like that. If you can have them in the same block code it would be easier to manage, but that’s all there is to it. Update: Apparently I forgot to mention, you will increase the size of your JavaScript code if you do this in multiple files.

    1. Is the order of execution same across all the browsers (IE,FF,etc)?

    Yes, because jQuery takes the cross-browser normalization at hand.

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

Sidebar

Related Questions

Let's say we have like 3 functions: // Notice there are no $(document).ready function
Let me give my question some context. I have a JavaScript widget. The widget
I have a FireWorks-generated HTML page and I added some jQuery to it for
An easy jQuery question. I have several identical forms ( except their name )
I have a question about using streams in .NET to load files from disk.
This perhaps is a more general jQuery (or even JavaScript) question: Basically I am
I have a question about some functionality I'm trying to add to my jQuery
I have posted a sample jQuery slideshow on my blog here: robertmarkbramprogrammer.blogspot.com/2010/09/jquery-slideshow.html In Chrome,
As per my previous question , I have a working animation which fades in
I have a login.jsp page which contains a login form. Once logged in the

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.