Hi Ernesto,

Since https://issues.apache.org/jira/browse/WICKET-4881 (6.4.0)  Wicket
combines all JS snippets (AjaxRequestTarget#append/prependJavaScript())
into at most one <evaluate-priority> and one <evaluate>. So this
optimization is in place in core.

For non-Ajax requests you can use
org.apache.wicket.markup.html.IHeaderResponseDecorator. You can again
collect all JS in a thread local (or in RequestCycle's metadata) and
contribute it as optimized JS call just before HeaderResponse#close().
I.e. instead of having N entries in Wicket.Event.add(window, 'domready',
function() { HERE }) you will have just one (the optimized) entry.


On Fri, Jan 25, 2013 at 12:15 PM, Ernesto Reinaldo Barreiro <
[email protected]> wrote:

> Hi,
>
> I recently had to optimize rendering times of some page with large number
> of components (e.g. date-pickers, auto-completes and so on). These
> components were part of a panel contributed via AJAX. So, in order to
> optimize rendering at client side I rolled out "collecting" versions of
> those components. To achieve this I
>
> 1- Divided the parameter to be passed to a widget on to sets: 1) 'Variable
> ones" (VA) and 2) relatively fixed ones (FA).
> 2- I created a thread local implementation of AjaxRequestTarget.IListener
> interface containing a Map<String, List<String>> where different widgets
> attributes will the collected along the AJAX request. So, instead of
> issuing an
>
> <evaluate>MyCompany.MyWidget.create({variable attributes},{fixed
> attributes});</evaluate>
>
> for each widget I do collect all that info as on the map as a par {FA,
> [VA1, VA2, ...VAN]} and at "the end" of the request cycle  I issue a single
>
> <evaluate>MyCompany.MyWidget.createMany({{FA},[{VA1},{VA2},....,{VAN}]});</
> evaluate>
>
>  After rendering this IListener would "detach" itself from the request's
> thread.
>
> The result is an improvement of rendering times at client side and a
> significant reduction of size of response (by a factor of 2 in our case).
>
> My questions are:
>
> -What could be used in place of AjaxRequestTarget.IListener for no AJAX
> requests? I haven't found a "hook" to handle this case:-( It would be nice
> to have a common "concept" that could be used for both cases.
> -Would it be worth to try such approach for some "core/extension"
> components? Already did it for 1.4.x version of datePicker
>
> --
> Regards - Ernesto Reinaldo Barreiro
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Reply via email to