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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:00:54+00:00 2026-06-11T15:00:54+00:00

When I peruse a jQuery-driven JavaScript source file, I see functions defined like so:

  • 0

When I peruse a jQuery-driven JavaScript source file, I see functions defined like so:

$(document).ready(function() {
    ...
});

$(function {
    ...
});

I think I understand the first one: I assume its a function to fire once the entire page is downloaded, yes? If not please correct me!

What really confuses me is the second one. Is this an anonymous function? How/where does it get called? When does it get called (page load)?

I guess I’m used to seeing JavaScript function written the old way:

function myFunction() {
    ...
}

Then I just call myFunction anytime I need it. How does this “old” way compare to jQuery’s constructs? Thanks for helping me understand any of this confusion!

  • 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-11T15:00:56+00:00Added an answer on June 11, 2026 at 3:00 pm

    The second function is just a short-hand method for the first method. Both register a callback for the document’s “ready” event.

    http://api.jquery.com/ready/

    All three of the following syntaxes are equivalent:

    $(document).ready(handler)
    $().ready(handler) (this is not recommended)
    $(handler)

    EDIT:
    The ready event actually fires when the DOM can be safely updated. The event will be raised before external resources like images are fully loaded, but most browsers appear to wait for extenal CSS to finish loading before calling it since scripts often depend on the layout calculations to be complete. The shorthand method jQuery method is very common since it provides an easy to remember and direct method for scripts to change the DOM when it’s, well, “ready” for the script.

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

Sidebar

Related Questions

In my current framework's design, I peruse all types of specific assemblies and do
Does anyone have any experience positioning the jquery.datepicker found at http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerClickInput.html Functionality-wise it works
In repository examples, I see the repository instantiated when the Session opens, which seems
I have a jquery Overlay over a div. It works pretty well, except, when
I am running Django (1.0.2) on Google App Engine, and would like to know
I've perused the Stack Exchange list of sites, and I can only think that
I'm using Wix to generate an msi installer file for a project. I'm using
Having recently had reason to peruse the Nullable documentation, I noticed that the definition
I've stripped down this function to what's causing the problem, but I'll try to
I have 4 entities that are related as follows: LocalAgency<-0..1----1->Agency<-0..1----1->Organization<-0..1----1->Customer In other words, a

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.