Shane Graber - jQuery schrieb:
> I've just begun using javascript and jquery and I'm very impressed
> with what can be acheived using it.  Thank you for an excellent
> product!  :)
> 
> This may seem like a basic question but I've just started working with
> javascript and am learning as I go.  Why is it that
> 
> $(document).ready(function() {
>     //stuff goes here
> });
> 
> is called directly within the document/page itself and not linked in
> as a file instead?  I see this on a consistent basis when I'm looking
> at plugin examples.  The written plugins themselves are linked in as a
> .js file but the actual javascript calls (
> $("#example").whatever(function()) ) are within the page itself and
> can be seen by viewing the page source.
> 
> Why is that?  Is there a performance boost?
> 
> Thanks,
> 
> Shane
> 

Most probably you were looking at demo pages. The part that goes into 
the ready event handler is not part of the plugin itself and instead it 
is up to the developer to initialize the plugin whereever he wants it.

Imagine the initialization would be part of the plugin: You would have 
no control over it at all and had to change that all the time most 
likely. Some people like to gather all these function calls into one 
"init" function, others like to call it wherever its necessary.


-- Klaus

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to