Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>I only see the act of putting script at different section of the page as a matter of executing it at different time. It is true?</p> </blockquote> <p>Yes, but the script you're talking about just makes a single function call (to <code>ready</code>). The callback will get called later, when the DOM is ready, either way.</p> <blockquote> <p>Can I put script in a div in the middle of the page?</p> </blockquote> <p>Yes. But again, if the script in question is just calling <code>ready</code> (directly, or via the shortcut), it doesn't much matter. I would discourage you from littering scripts all over your markup; best to try to keep the two largely separate.</p> <blockquote> <p>Will it affect how DOM is loaded?</p> </blockquote> <p>Only if you use <code>document.write</code> within the script (and even then, it doesn't affect how the DOM is loaded, but may affect the content of it).</p> <hr> <p>If you can choose where the <code>script</code> tags go (e.g., you're not writing a JavaScript library or jQuery plug-in, your script is on a page you control), there's little if any reason to use <code>ready</code>. Instead, put your script tag at the end of the page, just before the closing <code>&lt;/body&gt;</code> tag. References:</p> <ul> <li><a href="http://groups.google.com/group/closure-library-discuss/browse_thread/thread/1beecbb5d6afcb41" rel="nofollow">Google Closure engineers on when the DOM is ready</a></li> <li><a href="http://developer.yahoo.com/performance/rules.html" rel="nofollow">YUI Best Practices for Speeding Up your Website</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload