Hi, I'll take a stab at answer questions one and two:
On Jan 29, 2009, at 1:25 AM, B wrote:
1) When you bind elements on document.ready(), isn't that more inefficient than using the onclick() etc function available inside the markup. When you bind the events on document.ready() you have to traverse the DOM to locate each element to bind the event to adding extra over head. I am working on a website which currently has around a 100 different events on a page, and normally I just use the onclick, onmouseover function available in the <a href> markup to define these event while passing $(this) as a parameter, giving me access to the caller and preventing the extra work needed to bind the events. Example <a href="#" onclick="myFunction($(this))">my function call </ a>. Am I wrong in my reasoning that this is more efficient than binding on document.ready() ?
As donb mentioned, event delegation is a great way to avoid the inefficiency of binding events to many elements. jQuery 1.3.x has a .live() method for this.
If you want to see an example of this, take a look at my simpleTip plugin demo, which has tooltips working with 2,002 links (mouseover / mouseout):
http://plugins.learningjquery.com/simpletip/demo/
2) Also if you had an extremely long page and you bound events on document.ready() wouldn't there be instances where the javascript would not be immediately available while the page is loading? I have read that it is recommended when using hidden text or hidden areas to not set the display:none inside the css, but instead use a javascript function call on document.ready() to hide them. This has the advantage of preventing the text to be hidden for users who have javascript disabled. Wouldnt this again have the issue of the hidden text flashing on the screen?
You can get around this problem pretty easily: http://www.learningjquery.com/2008/10/1-awesome-way-to-avoid-the-not-so-excellent-flash-of-amazing-unstyled-content --Karl ____________ Karl Swedberg www.englishrules.com www.learningjquery.com