Re: Cross-Browser Mouse Event Handling
- From: "Richard Cornford" <Richard@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 2 Feb 2009 23:54:21 -0000
Garrett Smith wrote:
Thomas 'PointedEars' Lahn wrote:Garrett Smith wrote:kangax wrote:Thomas 'PointedEars' Lahn wrote:[snip]Martin Rinehart wrote:But don't event handler attributes have their own problems
- notably a somewhat idiotic scope augmentation?
Wouldn't it be recommended to use something along these lines:
The approach of assigning an event handler via script separates
the attachment from from the content, so the script can be moved
around to different place in the document.
And completely separating the function from the markup it is
operating on (and with) is a Good Thing, because ...?
"so the script can be moved around to different place in the
document"
That is not much of a justification. For a start it is not true; you can move the functions that are created from intrinsic event handlers around if you wanted to. After all, they should not be written to use their augmented scope chains as the augmentation itself is not guaranteed to happen at all, and is inconsistent between browsers where it does happen, and simultaneously that code should be written with the anticipation of the worst-case augmentation (where the element and all of its ancestors in the DOM hierarchy are added to the scope chain).
A better justification would being able to use the same code with many intrinsic events without suffering the overhead of creating many function objects. Though someone is likely to mention event delegation in response to that point.
<snip>
<snip>to allow the contents to render without being blocked by
one or more top scripts.
That story gets put about as if it is some sort of universal panacea. When the contents that the reader is interested in are at the top of the document then putting them where they can be read as soon as possible might be a good ides. But it can be an irritating pain if what you are interested in is at the bottom of the page (such as the latest comments on a blog that you have already read) and the loading of the scripts at the bottom of the page block the ability to scroll. In that case I would rather not have the top of the page sitting there taunting me while the browser is not allowing me to scroll to what I am interested in.
It may be that the real issue is attempting to download too much script code, and playing around with where that code is loaded is just playing with the symptoms rather than addressing the cause.
Richard.
.
- Follow-Ups:
- Re: Cross-Browser Mouse Event Handling
- From: Garrett Smith
- Re: Cross-Browser Mouse Event Handling
- From: RobG
- Re: Cross-Browser Mouse Event Handling
- References:
- Cross-Browser Mouse Event Handling
- From: Martin Rinehart
- Re: Cross-Browser Mouse Event Handling
- From: Thomas 'PointedEars' Lahn
- Re: Cross-Browser Mouse Event Handling
- From: kangax
- Re: Cross-Browser Mouse Event Handling
- From: Garrett Smith
- Re: Cross-Browser Mouse Event Handling
- From: Thomas 'PointedEars' Lahn
- Re: Cross-Browser Mouse Event Handling
- From: Garrett Smith
- Cross-Browser Mouse Event Handling
- Prev by Date: Re: Cross-Browser Mouse Event Handling
- Next by Date: Re: Cross-Browser onmousedown JavaScript
- Previous by thread: Re: Cross-Browser Mouse Event Handling
- Next by thread: Re: Cross-Browser Mouse Event Handling
- Index(es):
Relevant Pages
|