[jQuery] Why do a recursion while window unload?
<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Another question, in jquery.js(include version 1.2.3, 1.2.6 etc.) why add this code:</div><div> 1. // Prevent memory leaks in IE </div><div> 2. // And prevent errors on refresh with events like mouseover in other browsers </div><div> 3. // Window isn't included so as not to unbind existing unload events </div><div> 4. jQuery(window).bind("unload", function() { </div><div> 5. jQuery("*").add(document).unbind(); </div><div> 6. }); </div><div>
</div><div>This makes closing/refresh/navigate window more slow, especially the page is large(has many html elements).</div><div>
</div><div>Why not "have a definite object in view"? Do necessary unbind operation.</div><div>
</div><div>To say the least, wrap this code block with:</div><div>
</div><div>if (ie) {</div><div> 1. // Prevent memory leaks in IE </div><div> 2. // And prevent errors on refresh with events like mouseover in other browsers </div><div> 3. // Window isn't included so as not to unbind existing unload events </div><div> 4. jQuery(window).bind("unload", function() { </div><div> 5. jQuery("*").add(document).unbind(); </div><div> 6. }); </div><div>}</div></body></html>