Re: 5.4 JavaScript: Explicit vs. Unobtrusive initialization

2012-11-09 Thread Massimo Lusetti
BTW I've run the fiddle on my box several times and here are the average:

idLookup took: 6ms, found:1000
dataLookup took: 8ms, found: 1000

Cheers


On Fri, Nov 9, 2012 at 6:45 PM, Howard Lewis Ship  wrote:

> I'm working on a revised DateField right now, and driving it towards the
> unobtrusive approach instead of the explicit approach.
>
>
> On Fri, Nov 9, 2012 at 6:42 AM, Massimo Lusetti 
> wrote:
>
> > On Thu, Nov 8, 2012 at 6:32 PM, Howard Lewis Ship 
> > wrote:
> >
> > I modified the fiddle to loop 100 times; this will partially account for
> > > cachine, and MV optimizations.  By the last round:
> > >
> > > idLookup: 2ms
> > > dataLookup: 15ms
> > >
> > > Still, tiny amounts of time.
> > >
> >
> > I would definitely prefer the attribute driver approach even in case of a
> > need of a complete scan on each page or section.
> >
> > Said that I would ask if that time would increase with and increase in
> the
> > complexity of the page? How many "fiddle" elements (maybe compared to id
> > elements) could have a page like GMail ?
> >
> > One more think to note is: since more and more communities are going
> > towards a "data-" like approach I think that that sentiment could drive
> the
> > future developments of javascript frameworks and javascript engines.
> >
> > Cheers
> > --
> > Massimo
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator of Apache Tapestry
>
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
>
> (971) 678-5210
> http://howardlewisship.com
>



-- 
Massimo
http://meridio.blogspot.com


Re: 5.4 JavaScript: Explicit vs. Unobtrusive initialization

2012-11-09 Thread Howard Lewis Ship
I'm working on a revised DateField right now, and driving it towards the
unobtrusive approach instead of the explicit approach.


On Fri, Nov 9, 2012 at 6:42 AM, Massimo Lusetti  wrote:

> On Thu, Nov 8, 2012 at 6:32 PM, Howard Lewis Ship 
> wrote:
>
> I modified the fiddle to loop 100 times; this will partially account for
> > cachine, and MV optimizations.  By the last round:
> >
> > idLookup: 2ms
> > dataLookup: 15ms
> >
> > Still, tiny amounts of time.
> >
>
> I would definitely prefer the attribute driver approach even in case of a
> need of a complete scan on each page or section.
>
> Said that I would ask if that time would increase with and increase in the
> complexity of the page? How many "fiddle" elements (maybe compared to id
> elements) could have a page like GMail ?
>
> One more think to note is: since more and more communities are going
> towards a "data-" like approach I think that that sentiment could drive the
> future developments of javascript frameworks and javascript engines.
>
> Cheers
> --
> Massimo
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com


Re: 5.4 JavaScript: Explicit vs. Unobtrusive initialization

2012-11-09 Thread Massimo Lusetti
On Thu, Nov 8, 2012 at 6:32 PM, Howard Lewis Ship  wrote:

I modified the fiddle to loop 100 times; this will partially account for
> cachine, and MV optimizations.  By the last round:
>
> idLookup: 2ms
> dataLookup: 15ms
>
> Still, tiny amounts of time.
>

I would definitely prefer the attribute driver approach even in case of a
need of a complete scan on each page or section.

Said that I would ask if that time would increase with and increase in the
complexity of the page? How many "fiddle" elements (maybe compared to id
elements) could have a page like GMail ?

One more think to note is: since more and more communities are going
towards a "data-" like approach I think that that sentiment could drive the
future developments of javascript frameworks and javascript engines.

Cheers
-- 
Massimo


Re: 5.4 JavaScript: Explicit vs. Unobtrusive initialization

2012-11-08 Thread Howard Lewis Ship
Maybe Tapestry should automatically display a "Switch to Chrome" alert if
it detects IE :-)


On Thu, Nov 8, 2012 at 10:32 AM, Thiago H de Paula Figueiredo <
thiag...@gmail.com> wrote:

> On Thu, 08 Nov 2012 15:32:56 -0200, Howard Lewis Ship 
> wrote:
>
>  I modified the fiddle to loop 100 times; this will partially account for
>> cachine, and MV optimizations.  By the last round:
>>
>> idLookup: 2ms
>> dataLookup: 15ms
>>
>> Still, tiny amounts of time.
>>
>
> Which browser? Anyway, even hating IE as much as I do, specially old
> versions, in one project we needed to remove proper JS event listeners and
> replace them with onxxx atributes because IE8 couldn't handle them without
> slowing to a crawl in long pages.
>
> --
> Thiago H. de Paula Figueiredo
>
>
> --**--**-
> To unsubscribe, e-mail: 
> dev-unsubscribe@tapestry.**apache.org
> For additional commands, e-mail: dev-h...@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com


Re: 5.4 JavaScript: Explicit vs. Unobtrusive initialization

2012-11-08 Thread Thiago H de Paula Figueiredo
On Thu, 08 Nov 2012 15:32:56 -0200, Howard Lewis Ship   
wrote:



I modified the fiddle to loop 100 times; this will partially account for
cachine, and MV optimizations.  By the last round:

idLookup: 2ms
dataLookup: 15ms

Still, tiny amounts of time.


Which browser? Anyway, even hating IE as much as I do, specially old  
versions, in one project we needed to remove proper JS event listeners and  
replace them with onxxx atributes because IE8 couldn't handle them without  
slowing to a crawl in long pages.


--
Thiago H. de Paula Figueiredo

-
To unsubscribe, e-mail: dev-unsubscr...@tapestry.apache.org
For additional commands, e-mail: dev-h...@tapestry.apache.org



Re: 5.4 JavaScript: Explicit vs. Unobtrusive initialization

2012-11-08 Thread Howard Lewis Ship
I modified the fiddle to loop 100 times; this will partially account for
cachine, and MV optimizations.  By the last round:

idLookup: 2ms
dataLookup: 15ms

Still, tiny amounts of time.




On Thu, Nov 8, 2012 at 4:45 AM, Lance Java wrote:

> Here's a first attempt at benchmarking the differences:
> http://jsfiddle.net/xPVy6/6/
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/5-4-JavaScript-Explicit-vs-Unobtrusive-initialization-tp5717787p5717818.html
> Sent from the Tapestry - Dev mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: dev-h...@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com


Re: 5.4 JavaScript: Explicit vs. Unobtrusive initialization

2012-11-08 Thread Ulrich Stärk
I guess this comes down to the question of what is cheaper: A few more cycles 
spent on the client
side for scanning the document multiple times, or sticking to explicit 
initialization with all its
drawbacks. I believe we are talking about a few milliseconds spent with 
additional scanning, and
even if it went into the hundreds, everything below 500ms probably won't even 
be noticed by a user.

I'd go with unobstrusive only.

Uli

On 07.11.2012 18:17, Howard Lewis Ship wrote:
> One of the major changes taking place in the 5.4 branch is the choice
> between explicit initialization and unobtrusive initialization.
> 
> Tapestry has traditionally used explicit initialization:
> - render and element, with a specific id
> - generate "parameters" object that describes the behavior, and references
> that id
> - import a JavaScript library that provides a T5.initializers function
> - Invoke that function with the parameters object when the page loads
> 
> With 5.4, we're leveraging unobtrusive initialization. In this style,
> specific elements have special class names (or, increasingly, data-
> attributes).  A module is imported that provides a document-level event
> handler for events (both DOM events, and custom events) that originate in
> such elements.
> 
> Sometimes groups of data-attributes work together, for example in 5.4,
> validation now looks something like this:
> 
>  data-required-message="You most provide a user name."/>
> 
> What's nice about this approach is that, when new content is added to the
> page via Ajax or DHTML, the underlying validation behavior is instantly in
> place ... no wait of any kind for initialization, and no processing time
> spent performing the initialization. Likewise, if content is removed from
> the DOM, there's no possibility (even in IE) of memory leaks from cycles
> between JavaScript objects and closures, and DOM objects.
> 
> A nice note about this is that even elements that are rendered entirely on
> the client (perhaps using Backbone, as with my main client projects) can
> now pretty easily participate in validation, just by providing the right
> data- attributes.  At some point, we'll need to create a dictionary of
> these different attributes and how they related to each other!
> 
> This unobtrusive, attribute-driven, approach works great on things that are
> rendered entirely the server side. As I'm recoding more sophisticated
> components, such as the Palette, I'm hitting components that want to do
> some rendering or setup on the client. Even here, there's room for explicit
> or unobtrusive.
> 
> To accomplish unobtrusive, we could do a scan when the page loads for
> elements; for instance, the Palette component could render a
> data-component-type="core/Palette" attribute, and code inside the
> core/palette module could locate such elements and wire them up.
> 
> The challenge there is that, on an Ajax update, we need to scan the newly
> added content and the DOM does not directly provide a way to do that.
> However, the Zone component (and other things that act like a Zone) emit
> custom events before and after updating the DOM.  So we could do one scan
> on initial page load, and an additional scan, just on updated zone content,
> whenever a zone does in fact update.
> 
> The advantage here is moving away from Tapestry-generated unique ids, and
> all the confusion associated with them.
> 
> Has anyone else pursued the unobstrusive/scanning approach (outside of
> Tapestry)?
> 
> Currently, the work I'm doing on Palette leaves it in the explicit
> initialization camp. The trade-off for me is the expense of lots of
> document scans looking for elements to initialize; I'm sure a larger app
> with many big custom components could end up spending a lot of cycles doing
> just that after every dynamic update. However, the appeal of going "id
> free" is compelling.
> 
> 


-
To unsubscribe, e-mail: dev-unsubscr...@tapestry.apache.org
For additional commands, e-mail: dev-h...@tapestry.apache.org



Re: 5.4 JavaScript: Explicit vs. Unobtrusive initialization

2012-11-08 Thread trsvax
If I understand your question correctly you are trying to figure out if it's
better to initialize the javascript elements on the client side by id or by
some other kind of selector.

I use both Bootstrap and the Facebook apis and they both use data elements
and then automatically initialize the various widgets. As you say this does
not work in Zones so I created a run once javascript addition to
JavaScriptSupport to handle this. 

I did run across this benchmark which might be apply to zones. It appears

$(container).children('') is faster than $('container.children')

http://seesparkbox.com/foundry/jquery_selector_performance_testing

The good thing about that is container could be 'body' for a page load and
the zone id for a zone load. 



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/5-4-JavaScript-Explicit-vs-Unobtrusive-initialization-tp5717787p5717819.html
Sent from the Tapestry - Dev mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: dev-unsubscr...@tapestry.apache.org
For additional commands, e-mail: dev-h...@tapestry.apache.org



Re: 5.4 JavaScript: Explicit vs. Unobtrusive initialization

2012-11-08 Thread Lance Java
Here's a first attempt at benchmarking the differences:
http://jsfiddle.net/xPVy6/6/



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/5-4-JavaScript-Explicit-vs-Unobtrusive-initialization-tp5717787p5717818.html
Sent from the Tapestry - Dev mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: dev-unsubscr...@tapestry.apache.org
For additional commands, e-mail: dev-h...@tapestry.apache.org



Re: 5.4 JavaScript: Explicit vs. Unobtrusive initialization

2012-11-08 Thread Lance Java
Sounds to me like a benchmark is needed to compare id lookup against full DOM
scan for data attributes on all the major browsers on small, medium and
large web pages.



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/5-4-JavaScript-Explicit-vs-Unobtrusive-initialization-tp5717787p5717811.html
Sent from the Tapestry - Dev mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: dev-unsubscr...@tapestry.apache.org
For additional commands, e-mail: dev-h...@tapestry.apache.org