On Feb 3, 1:38 pm, Fran <[email protected]> wrote:
> I like this really tiny but clever plugin. I'll definitely keep it in
> mine, but still I have the question whether using $(document) or
> $('body') makes any different. Any idea ?
>
> Thanks
>
> On 03/02/11 12:12, Mads Erik Forberg wrote:
>
> > Den 03.02.2011 13:03, skrev Fran:
> >> Hi guys,
>
> >> I know this is more jQuery related question and perhaps it'd be
> >> better to ask in its forum but I'll drop it in case some jQuery
> >> experts in this group could answer it. Is there any reason why I
> >> should be using "$(document).bind/trigger" over
> >> "$('body').bind/trigger" (or the other way around) if I wanted to use
> >> it as a PubSub ? Any different in terms of performance or others ?
>
> >> Thanks
>
> > Hello,
>
> > maybe it's worth checking out this jQuery plugin for your pub/sub
> > needs:https://gist.github.com/661855

One of the main difference is that by binding events to "document"
node ensures you can attach handler code as soon as possible without
having to block the load waiting for some signal that tells you can
start.

Binding to the "body" element will need an "onload/ready" event to
ensure the "body" is present, this requirement alone, in turn,
normally forces people to use a library when not strictly necessary.

Obviously $(document) and/or $('body') also presumes a lot of code is
needed to select the elements through a selector engine when for the
simple case outlines it would have been easier to access them
directly.


--
Diego

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to