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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:17:55+00:00 2026-05-22T02:17:55+00:00

I’m curious what situations exactly require the use of jquery’s $(document).ready() or prototype’s dom:loaded

  • 0

I’m curious what situations exactly require the use of jquery’s $(document).ready() or prototype’s dom:loaded or any other variant of a handler for this event.

In all the browsers i’ve tested, it’s entirely acceptable to begin interacting with html elements and the DOM immediately after the closing tag. (e.g.

<div id="myID">
 My Div
</div>
<script type="text/javascript">
$('#myID').initializeElement();
</script>

So at this point i’m wondering whether $(document).ready() is merely there to reduce the thinking involved in writing javascript code that runs during page load. In the case of using $(document).ready() there is regularly rendering issues such as popping and ‘artifacts’ between the browser first starting to draw the page and the javascript actually executing when the page is ‘ready’.

Are there any scenarios where $(document).ready() is required?

Are there any reasons I shouldn’t be writing initialization scripts as demonstrated?

  • 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-22T02:17:55+00:00Added an answer on May 22, 2026 at 2:17 am

    In the case of external scripts $(document).ready() could be the only option. As for inline script it is a little different.

    According to HTML 4.01 standard it seems a little ambiguous whether or not the initialization technique shown above is legal:

    http://www.w3.org/TR/html401/interact/scripts.html#h-18.2.4

    Scripts that are executed when a document is loaded may be able to
    modify the document’s contents
    dynamically. The ability to do so
    depends on the scripting language
    itself (e.g., the “document.write”
    statement in the HTML object model
    supported by some vendors).

    HTML documents are constrained to conform to the HTML DTD both before
    and after processing any SCRIPT
    elements.

    In the HTML 5 draft it seems very clear that this practice is fully supported:

    http://www.w3.org/TR/html5/scripting-1.html#scripting-1

    The following sample shows how a
    script element can be used to define a
    function that is then used by other
    parts of the document. It also shows
    how a script element can be used to
    invoke script while the document is
    being parsed, in this case to
    initialize the form’s output.

    <script>
     function calculate(form) {
       var price = 52000;
       if (form.elements.brakes.checked)
         price += 1000;
       if (form.elements.radio.checked)
         price += 2500;
       if (form.elements.turbo.checked)
         price += 5000;
       if (form.elements.sticker.checked)
         price += 250;
       form.elements.result.value = price;
     }
    </script>
    <form name="pricecalc" onsubmit="return false">
     <fieldset>
      <legend>Work out the price of your car</legend>
      <p>Base cost: £52000.</p>
      <p>Select additional options:</p>
      <ul onchange="calculate(form)">
       <li><label><input type=checkbox name=brakes> Ceramic brakes (£1000)</label></li>
       <li><label><input type=checkbox name=radio> Satellite radio (£2500)</label></li>
       <li><label><input type=checkbox name=turbo> Turbo charger (£5000)</label></li>
       <li><label><input type=checkbox name=sticker> "XZ" sticker (£250)</label></li>
      </ul>
      <p>Total: £<output name=result></output></p>
     </fieldset>
     <script>
      calculate(document.forms.pricecalc);
     </script>
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.