jquery - Is $(document).ready necessary?
<p>I am reading an online tutorial that says if the <code>&lt;script&gt;&lt;/script&gt;</code> is right on top of <code>&lt;/body&gt;</code> the <code>$(document).ready</code> is not necessary b/c the document has been loaded at that moment.</p>

<p>Q1> Is that true?</p>

<p>Q2> </p>

<pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"&gt;&lt;/script&gt;
&lt;script src="jquery.viewport.min.js"&gt;&lt;/script&gt;

&lt;script&gt;
$(window).scroll(function() { // this line will track all mouse scroll event

});
&lt;/script&gt;
</code></pre>

<p>What does the $(window) mean? Is this a jquery selector? If it is, then the previous claim looks correct because we don't have to include this inside</p>

<pre><code>$(document).ready(function() {

});
</code></pre>

<p>Q3> why we use $link here? why we choose to use <code>$link</code> rather than var link?</p>

<pre><code>&lt;script&gt;
$(window).scroll(function() {
  $link = $('nav a[hash=#first]');
  $link.addClass('selected');
});
&lt;/script&gt;
</code></pre>

<p>Thank you</p>
