Quantcast

JS performance optimization in AjaxRequestTarget

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

JS performance optimization in AjaxRequestTarget

Martin Grigorov-4
Hi,

Do you imagine a use case in which several <evaluate>s in
<ajax-response> should be executed separately (one after another) as
it is now ?
Each <evaluate> (and <priority-evaluate>) is executed in an eval() in
wicket-ajax.js. As we all know eval() is slow. As an optimization I
think we can merge all <evaluate>s in one (at server side) and eval
them all together. The only drawback I see is that error reporting
will be worse because the exception message will say "there is an
error in 'all JS in one <evaluate> here' "

--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JS performance optimization in AjaxRequestTarget

Bertrand Guay-Paquet
Hi,

Merging multiple evaluates together will change the scope of some
variables. The variables in the scope of an evaluate block would carry
on in the following evaluate blocks. This could however be mitigated by
wrapping each evaluate block in its own function.

Bertrand

On 08/02/2012 8:24 AM, Martin Grigorov wrote:

> Hi,
>
> Do you imagine a use case in which several<evaluate>s in
> <ajax-response>  should be executed separately (one after another) as
> it is now ?
> Each<evaluate>  (and<priority-evaluate>) is executed in an eval() in
> wicket-ajax.js. As we all know eval() is slow. As an optimization I
> think we can merge all<evaluate>s in one (at server side) and eval
> them all together. The only drawback I see is that error reporting
> will be worse because the exception message will say "there is an
> error in 'all JS in one<evaluate>  here' "
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JS performance optimization in AjaxRequestTarget

Martin Grigorov-4
On Wed, Feb 8, 2012 at 4:33 PM, Bertrand Guay-Paquet
<[hidden email]> wrote:
> Hi,
>
> Merging multiple evaluates together will change the scope of some variables.
> The variables in the scope of an evaluate block would carry on in the
> following evaluate blocks. This could however be mitigated by wrapping each
> evaluate block in its own function.

True.
Wrapping them in {} should be enough to prevent this problem.

>
> Bertrand
>
>
> On 08/02/2012 8:24 AM, Martin Grigorov wrote:
>>
>> Hi,
>>
>> Do you imagine a use case in which several<evaluate>s in
>> <ajax-response>  should be executed separately (one after another) as
>> it is now ?
>> Each<evaluate>  (and<priority-evaluate>) is executed in an eval() in
>> wicket-ajax.js. As we all know eval() is slow. As an optimization I
>> think we can merge all<evaluate>s in one (at server side) and eval
>> them all together. The only drawback I see is that error reporting
>> will be worse because the exception message will say "there is an
>> error in 'all JS in one<evaluate>  here' "
>>
>



--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JS performance optimization in AjaxRequestTarget

Papegaaij
This is very easy to accomplish in 6.0. You only have to delete the code that
keeps the scripts separate when AJAX :). I can fix this, if you want?

Emond

On Wednesday 08 February 2012 16:44:14 Martin Grigorov wrote:

> On Wed, Feb 8, 2012 at 4:33 PM, Bertrand Guay-Paquet
>
> <[hidden email]> wrote:
> > Hi,
> >
> > Merging multiple evaluates together will change the scope of some
> > variables. The variables in the scope of an evaluate block would carry on
> > in the following evaluate blocks. This could however be mitigated by
> > wrapping each evaluate block in its own function.
>
> True.
> Wrapping them in {} should be enough to prevent this problem.
>
> > Bertrand
> >
> > On 08/02/2012 8:24 AM, Martin Grigorov wrote:
> >> Hi,
> >>
> >> Do you imagine a use case in which several<evaluate>s in
> >> <ajax-response>  should be executed separately (one after another) as
> >> it is now ?
> >> Each<evaluate>  (and<priority-evaluate>) is executed in an eval() in
> >> wicket-ajax.js. As we all know eval() is slow. As an optimization I
> >> think we can merge all<evaluate>s in one (at server side) and eval
> >> them all together. The only drawback I see is that error reporting
> >> will be worse because the exception message will say "there is an
> >> error in 'all JS in one<evaluate>  here' "
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JS performance optimization in AjaxRequestTarget

Martin Grigorov-4
On Wed, Feb 8, 2012 at 4:50 PM, Emond Papegaaij
<[hidden email]> wrote:
> This is very easy to accomplish in 6.0. You only have to delete the code that
> keeps the scripts separate when AJAX :). I can fix this, if you want?

I think we talk about different things.
I talk about Ajax response:
<ajax-response>
  <evaluate> someJS1();</evaluate>
  <evaluate> someJS2();</evaluate>
  <evaluate> someJS3();</evaluate>
  <component id="someId"><div>new content</div>
</ajax-request>

>
> Emond
>
> On Wednesday 08 February 2012 16:44:14 Martin Grigorov wrote:
>> On Wed, Feb 8, 2012 at 4:33 PM, Bertrand Guay-Paquet
>>
>> <[hidden email]> wrote:
>> > Hi,
>> >
>> > Merging multiple evaluates together will change the scope of some
>> > variables. The variables in the scope of an evaluate block would carry on
>> > in the following evaluate blocks. This could however be mitigated by
>> > wrapping each evaluate block in its own function.
>>
>> True.
>> Wrapping them in {} should be enough to prevent this problem.
>>
>> > Bertrand
>> >
>> > On 08/02/2012 8:24 AM, Martin Grigorov wrote:
>> >> Hi,
>> >>
>> >> Do you imagine a use case in which several<evaluate>s in
>> >> <ajax-response>  should be executed separately (one after another) as
>> >> it is now ?
>> >> Each<evaluate>  (and<priority-evaluate>) is executed in an eval() in
>> >> wicket-ajax.js. As we all know eval() is slow. As an optimization I
>> >> think we can merge all<evaluate>s in one (at server side) and eval
>> >> them all together. The only drawback I see is that error reporting
>> >> will be worse because the exception message will say "there is an
>> >> error in 'all JS in one<evaluate>  here' "



--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JS performance optimization in AjaxRequestTarget

Papegaaij
In Wicket 6, onDomReady and onLoad scripts are merged into one big script in
the ResourceAggregator. This is to prevent many script tags, all with
$(document).ready(function(){...}) (or the wicket equivalent). This merging is
only done for non-AJAX requests, to preserve the separate evaluates. Removing
this check, will merge all evals into one.

One side note, the {}s are not added yet.

Emond

On Wednesday 08 February 2012 16:54:17 Martin Grigorov wrote:

> On Wed, Feb 8, 2012 at 4:50 PM, Emond Papegaaij
>
> <[hidden email]> wrote:
> > This is very easy to accomplish in 6.0. You only have to delete the code
> > that keeps the scripts separate when AJAX :). I can fix this, if you
> > want?
> I think we talk about different things.
> I talk about Ajax response:
> <ajax-response>
>   <evaluate> someJS1();</evaluate>
>   <evaluate> someJS2();</evaluate>
>   <evaluate> someJS3();</evaluate>
>   <component id="someId"><div>new content</div>
> </ajax-request>
>
> > Emond
> >
> > On Wednesday 08 February 2012 16:44:14 Martin Grigorov wrote:
> >> On Wed, Feb 8, 2012 at 4:33 PM, Bertrand Guay-Paquet
> >>
> >> <[hidden email]> wrote:
> >> > Hi,
> >> >
> >> > Merging multiple evaluates together will change the scope of some
> >> > variables. The variables in the scope of an evaluate block would carry
> >> > on
> >> > in the following evaluate blocks. This could however be mitigated by
> >> > wrapping each evaluate block in its own function.
> >>
> >> True.
> >> Wrapping them in {} should be enough to prevent this problem.
> >>
> >> > Bertrand
> >> >
> >> > On 08/02/2012 8:24 AM, Martin Grigorov wrote:
> >> >> Hi,
> >> >>
> >> >> Do you imagine a use case in which several<evaluate>s in
> >> >> <ajax-response>  should be executed separately (one after another) as
> >> >> it is now ?
> >> >> Each<evaluate>  (and<priority-evaluate>) is executed in an eval() in
> >> >> wicket-ajax.js. As we all know eval() is slow. As an optimization I
> >> >> think we can merge all<evaluate>s in one (at server side) and eval
> >> >> them all together. The only drawback I see is that error reporting
> >> >> will be worse because the exception message will say "there is an
> >> >> error in 'all JS in one<evaluate>  here' "
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JS performance optimization in AjaxRequestTarget

Martin Grigorov-4
On Wed, Feb 8, 2012 at 5:01 PM, Emond Papegaaij
<[hidden email]> wrote:
> In Wicket 6, onDomReady and onLoad scripts are merged into one big script in
> the ResourceAggregator. This is to prevent many script tags, all with
> $(document).ready(function(){...}) (or the wicket equivalent). This merging is
> only done for non-AJAX requests, to preserve the separate evaluates. Removing
> this check, will merge all evals into one.

There are no evals in non-Ajax response. So this is OK.

>
> One side note, the {}s are not added yet.

We should add them.

>
> Emond
>
> On Wednesday 08 February 2012 16:54:17 Martin Grigorov wrote:
>> On Wed, Feb 8, 2012 at 4:50 PM, Emond Papegaaij
>>
>> <[hidden email]> wrote:
>> > This is very easy to accomplish in 6.0. You only have to delete the code
>> > that keeps the scripts separate when AJAX :). I can fix this, if you
>> > want?
>> I think we talk about different things.
>> I talk about Ajax response:
>> <ajax-response>
>>   <evaluate> someJS1();</evaluate>
>>   <evaluate> someJS2();</evaluate>
>>   <evaluate> someJS3();</evaluate>
>>   <component id="someId"><div>new content</div>
>> </ajax-request>
>>
>> > Emond
>> >
>> > On Wednesday 08 February 2012 16:44:14 Martin Grigorov wrote:
>> >> On Wed, Feb 8, 2012 at 4:33 PM, Bertrand Guay-Paquet
>> >>
>> >> <[hidden email]> wrote:
>> >> > Hi,
>> >> >
>> >> > Merging multiple evaluates together will change the scope of some
>> >> > variables. The variables in the scope of an evaluate block would carry
>> >> > on
>> >> > in the following evaluate blocks. This could however be mitigated by
>> >> > wrapping each evaluate block in its own function.
>> >>
>> >> True.
>> >> Wrapping them in {} should be enough to prevent this problem.
>> >>
>> >> > Bertrand
>> >> >
>> >> > On 08/02/2012 8:24 AM, Martin Grigorov wrote:
>> >> >> Hi,
>> >> >>
>> >> >> Do you imagine a use case in which several<evaluate>s in
>> >> >> <ajax-response>  should be executed separately (one after another) as
>> >> >> it is now ?
>> >> >> Each<evaluate>  (and<priority-evaluate>) is executed in an eval() in
>> >> >> wicket-ajax.js. As we all know eval() is slow. As an optimization I
>> >> >> think we can merge all<evaluate>s in one (at server side) and eval
>> >> >> them all together. The only drawback I see is that error reporting
>> >> >> will be worse because the exception message will say "there is an
>> >> >> error in 'all JS in one<evaluate>  here' "



--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

RE: JS performance optimization in AjaxRequestTarget

Burton, Tom (DOR sponsored)
In reply to this post by Martin Grigorov-4
I hope I'm not speaking out of turn.  However, with regards to:
                The only drawback I see is that error reporting
        will be worse because the exception message will say "there is an
        error in 'all JS in one <evaluate> here' "
What if they combining for efficiency was only done on `DEPLOYMENT`?  That way when a user is developing a page and debugging the JavaScript the error message will be more useful. (provided {} and/or function() truly is enough to solve variable scoping issues.)


Tom Burton



-----Original Message-----
From: Martin Grigorov [mailto:[hidden email]]
Sent: Wednesday, February 08, 2012 4:25 AM
To: [hidden email]
Subject: JS performance optimization in AjaxRequestTarget

Hi,

Do you imagine a use case in which several <evaluate>s in
<ajax-response> should be executed separately (one after another) as
it is now ?
Each <evaluate> (and <priority-evaluate>) is executed in an eval() in
wicket-ajax.js. As we all know eval() is slow. As an optimization I
think we can merge all <evaluate>s in one (at server side) and eval
them all together. The only drawback I see is that error reporting
will be worse because the exception message will say "there is an
error in 'all JS in one <evaluate> here' "

--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JS performance optimization in AjaxRequestTarget

Martin Grigorov-4
On Wed, Feb 8, 2012 at 8:30 PM, Burton, Tom F (DOR)
<[hidden email]> wrote:
> I hope I'm not speaking out of turn.  However, with regards to:
>                The only drawback I see is that error reporting
>        will be worse because the exception message will say "there is an
>        error in 'all JS in one <evaluate> here' "
> What if they combining for efficiency was only done on `DEPLOYMENT`?  That way when a user is developing a page and debugging the JavaScript the error message will be more useful. (provided {} and/or function() truly is enough to solve variable scoping issues.)

Agree!

>
>
> Tom Burton
>
>
>
> -----Original Message-----
> From: Martin Grigorov [mailto:[hidden email]]
> Sent: Wednesday, February 08, 2012 4:25 AM
> To: [hidden email]
> Subject: JS performance optimization in AjaxRequestTarget
>
> Hi,
>
> Do you imagine a use case in which several <evaluate>s in
> <ajax-response> should be executed separately (one after another) as
> it is now ?
> Each <evaluate> (and <priority-evaluate>) is executed in an eval() in
> wicket-ajax.js. As we all know eval() is slow. As an optimization I
> think we can merge all <evaluate>s in one (at server side) and eval
> them all together. The only drawback I see is that error reporting
> will be worse because the exception message will say "there is an
> error in 'all JS in one <evaluate> here' "
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com



--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JS performance optimization in AjaxRequestTarget

Frank van Lankvelt-3
In reply to this post by Papegaaij

On 8 feb. 2012, at 16:01, Emond Papegaaij <[hidden email]> wrote:

> In Wicket 6, onDomReady and onLoad scripts are merged into one big script in
> the ResourceAggregator. This is to prevent many script tags, all with
> $(document).ready(function(){...}) (or the wicket equivalent). This merging is
> only done for non-AJAX requests, to preserve the separate evaluates. Removing
> this check, will merge all evals into one.
>
> One side note, the {}s are not added yet.
>
I'm not sure if this was implemented already, but javascript blocks do not limit the scope of variables.  See e.g. Crockford http://javascript.crockford.com/code.html
The only way to limit scope is to use functions, according to this document.

Cheers, Frank

> Emond
>
> On Wednesday 08 February 2012 16:54:17 Martin Grigorov wrote:
>> On Wed, Feb 8, 2012 at 4:50 PM, Emond Papegaaij
>>
>> <[hidden email]> wrote:
>>> This is very easy to accomplish in 6.0. You only have to delete the code
>>> that keeps the scripts separate when AJAX :). I can fix this, if you
>>> want?
>> I think we talk about different things.
>> I talk about Ajax response:
>> <ajax-response>
>>  <evaluate> someJS1();</evaluate>
>>  <evaluate> someJS2();</evaluate>
>>  <evaluate> someJS3();</evaluate>
>>  <component id="someId"><div>new content</div>
>> </ajax-request>
>>
>>> Emond
>>>
>>> On Wednesday 08 February 2012 16:44:14 Martin Grigorov wrote:
>>>> On Wed, Feb 8, 2012 at 4:33 PM, Bertrand Guay-Paquet
>>>>
>>>> <[hidden email]> wrote:
>>>>> Hi,
>>>>>
>>>>> Merging multiple evaluates together will change the scope of some
>>>>> variables. The variables in the scope of an evaluate block would carry
>>>>> on
>>>>> in the following evaluate blocks. This could however be mitigated by
>>>>> wrapping each evaluate block in its own function.
>>>>
>>>> True.
>>>> Wrapping them in {} should be enough to prevent this problem.
>>>>
>>>>> Bertrand
>>>>>
>>>>> On 08/02/2012 8:24 AM, Martin Grigorov wrote:
>>>>>> Hi,
>>>>>>
>>>>>> Do you imagine a use case in which several<evaluate>s in
>>>>>> <ajax-response>  should be executed separately (one after another) as
>>>>>> it is now ?
>>>>>> Each<evaluate>  (and<priority-evaluate>) is executed in an eval() in
>>>>>> wicket-ajax.js. As we all know eval() is slow. As an optimization I
>>>>>> think we can merge all<evaluate>s in one (at server side) and eval
>>>>>> them all together. The only drawback I see is that error reporting
>>>>>> will be worse because the exception message will say "there is an
>>>>>> error in 'all JS in one<evaluate>  here' "
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JS performance optimization in AjaxRequestTarget

Martin Grigorov-4
On Thu, Feb 9, 2012 at 6:16 PM, Frank van Lankvelt <[hidden email]> wrote:

>
> On 8 feb. 2012, at 16:01, Emond Papegaaij <[hidden email]> wrote:
>
>> In Wicket 6, onDomReady and onLoad scripts are merged into one big script in
>> the ResourceAggregator. This is to prevent many script tags, all with
>> $(document).ready(function(){...}) (or the wicket equivalent). This merging is
>> only done for non-AJAX requests, to preserve the separate evaluates. Removing
>> this check, will merge all evals into one.
>>
>> One side note, the {}s are not added yet.
>>
> I'm not sure if this was implemented already, but javascript blocks do not limit the scope of variables.  See e.g. Crockford http://javascript.crockford.com/code.html
> The only way to limit scope is to use functions, according to this document.

Correct. My mistake.

>
> Cheers, Frank
>
>> Emond
>>
>> On Wednesday 08 February 2012 16:54:17 Martin Grigorov wrote:
>>> On Wed, Feb 8, 2012 at 4:50 PM, Emond Papegaaij
>>>
>>> <[hidden email]> wrote:
>>>> This is very easy to accomplish in 6.0. You only have to delete the code
>>>> that keeps the scripts separate when AJAX :). I can fix this, if you
>>>> want?
>>> I think we talk about different things.
>>> I talk about Ajax response:
>>> <ajax-response>
>>>  <evaluate> someJS1();</evaluate>
>>>  <evaluate> someJS2();</evaluate>
>>>  <evaluate> someJS3();</evaluate>
>>>  <component id="someId"><div>new content</div>
>>> </ajax-request>
>>>
>>>> Emond
>>>>
>>>> On Wednesday 08 February 2012 16:44:14 Martin Grigorov wrote:
>>>>> On Wed, Feb 8, 2012 at 4:33 PM, Bertrand Guay-Paquet
>>>>>
>>>>> <[hidden email]> wrote:
>>>>>> Hi,
>>>>>>
>>>>>> Merging multiple evaluates together will change the scope of some
>>>>>> variables. The variables in the scope of an evaluate block would carry
>>>>>> on
>>>>>> in the following evaluate blocks. This could however be mitigated by
>>>>>> wrapping each evaluate block in its own function.
>>>>>
>>>>> True.
>>>>> Wrapping them in {} should be enough to prevent this problem.
>>>>>
>>>>>> Bertrand
>>>>>>
>>>>>> On 08/02/2012 8:24 AM, Martin Grigorov wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> Do you imagine a use case in which several<evaluate>s in
>>>>>>> <ajax-response>  should be executed separately (one after another) as
>>>>>>> it is now ?
>>>>>>> Each<evaluate>  (and<priority-evaluate>) is executed in an eval() in
>>>>>>> wicket-ajax.js. As we all know eval() is slow. As an optimization I
>>>>>>> think we can merge all<evaluate>s in one (at server side) and eval
>>>>>>> them all together. The only drawback I see is that error reporting
>>>>>>> will be worse because the exception message will say "there is an
>>>>>>> error in 'all JS in one<evaluate>  here' "
>>



--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JS performance optimization in AjaxRequestTarget

Johan Compagner
In reply to this post by Frank van Lankvelt-3
or use the let statement.. but support in all browsers could be a bit
tricky ;)
shouild be javascript 1.7 (thats FF 2.0 from 2006) but i don't think its in
EcmaScript yet (looks like EcmaScript 6 gets it) and most other browsers
follow that and do currently Edition 5.x or something


On Thu, Feb 9, 2012 at 17:16, Frank van Lankvelt <[hidden email]>wrote:

>
> On 8 feb. 2012, at 16:01, Emond Papegaaij <[hidden email]>
> wrote:
>
> > In Wicket 6, onDomReady and onLoad scripts are merged into one big
> script in
> > the ResourceAggregator. This is to prevent many script tags, all with
> > $(document).ready(function(){...}) (or the wicket equivalent). This
> merging is
> > only done for non-AJAX requests, to preserve the separate evaluates.
> Removing
> > this check, will merge all evals into one.
> >
> > One side note, the {}s are not added yet.
> >
> I'm not sure if this was implemented already, but javascript blocks do not
> limit the scope of variables.  See e.g. Crockford
> http://javascript.crockford.com/code.html
> The only way to limit scope is to use functions, according to this
> document.
>
> Cheers, Frank
>
> > Emond
> >
> > On Wednesday 08 February 2012 16:54:17 Martin Grigorov wrote:
> >> On Wed, Feb 8, 2012 at 4:50 PM, Emond Papegaaij
> >>
> >> <[hidden email]> wrote:
> >>> This is very easy to accomplish in 6.0. You only have to delete the
> code
> >>> that keeps the scripts separate when AJAX :). I can fix this, if you
> >>> want?
> >> I think we talk about different things.
> >> I talk about Ajax response:
> >> <ajax-response>
> >>  <evaluate> someJS1();</evaluate>
> >>  <evaluate> someJS2();</evaluate>
> >>  <evaluate> someJS3();</evaluate>
> >>  <component id="someId"><div>new content</div>
> >> </ajax-request>
> >>
> >>> Emond
> >>>
> >>> On Wednesday 08 February 2012 16:44:14 Martin Grigorov wrote:
> >>>> On Wed, Feb 8, 2012 at 4:33 PM, Bertrand Guay-Paquet
> >>>>
> >>>> <[hidden email]> wrote:
> >>>>> Hi,
> >>>>>
> >>>>> Merging multiple evaluates together will change the scope of some
> >>>>> variables. The variables in the scope of an evaluate block would
> carry
> >>>>> on
> >>>>> in the following evaluate blocks. This could however be mitigated by
> >>>>> wrapping each evaluate block in its own function.
> >>>>
> >>>> True.
> >>>> Wrapping them in {} should be enough to prevent this problem.
> >>>>
> >>>>> Bertrand
> >>>>>
> >>>>> On 08/02/2012 8:24 AM, Martin Grigorov wrote:
> >>>>>> Hi,
> >>>>>>
> >>>>>> Do you imagine a use case in which several<evaluate>s in
> >>>>>> <ajax-response>  should be executed separately (one after another)
> as
> >>>>>> it is now ?
> >>>>>> Each<evaluate>  (and<priority-evaluate>) is executed in an eval() in
> >>>>>> wicket-ajax.js. As we all know eval() is slow. As an optimization I
> >>>>>> think we can merge all<evaluate>s in one (at server side) and eval
> >>>>>> them all together. The only drawback I see is that error reporting
> >>>>>> will be worse because the exception message will say "there is an
> >>>>>> error in 'all JS in one<evaluate>  here' "
> >
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JS performance optimization in AjaxRequestTarget

Martin Grigorov-4
https://issues.apache.org/jira/browse/WICKET-4418

there is a link to a benchmark

On Thu, Feb 9, 2012 at 11:13 PM, Johan Compagner <[hidden email]> wrote:

> or use the let statement.. but support in all browsers could be a bit
> tricky ;)
> shouild be javascript 1.7 (thats FF 2.0 from 2006) but i don't think its in
> EcmaScript yet (looks like EcmaScript 6 gets it) and most other browsers
> follow that and do currently Edition 5.x or something
>
>
> On Thu, Feb 9, 2012 at 17:16, Frank van Lankvelt <[hidden email]>wrote:
>
>>
>> On 8 feb. 2012, at 16:01, Emond Papegaaij <[hidden email]>
>> wrote:
>>
>> > In Wicket 6, onDomReady and onLoad scripts are merged into one big
>> script in
>> > the ResourceAggregator. This is to prevent many script tags, all with
>> > $(document).ready(function(){...}) (or the wicket equivalent). This
>> merging is
>> > only done for non-AJAX requests, to preserve the separate evaluates.
>> Removing
>> > this check, will merge all evals into one.
>> >
>> > One side note, the {}s are not added yet.
>> >
>> I'm not sure if this was implemented already, but javascript blocks do not
>> limit the scope of variables.  See e.g. Crockford
>> http://javascript.crockford.com/code.html
>> The only way to limit scope is to use functions, according to this
>> document.
>>
>> Cheers, Frank
>>
>> > Emond
>> >
>> > On Wednesday 08 February 2012 16:54:17 Martin Grigorov wrote:
>> >> On Wed, Feb 8, 2012 at 4:50 PM, Emond Papegaaij
>> >>
>> >> <[hidden email]> wrote:
>> >>> This is very easy to accomplish in 6.0. You only have to delete the
>> code
>> >>> that keeps the scripts separate when AJAX :). I can fix this, if you
>> >>> want?
>> >> I think we talk about different things.
>> >> I talk about Ajax response:
>> >> <ajax-response>
>> >>  <evaluate> someJS1();</evaluate>
>> >>  <evaluate> someJS2();</evaluate>
>> >>  <evaluate> someJS3();</evaluate>
>> >>  <component id="someId"><div>new content</div>
>> >> </ajax-request>
>> >>
>> >>> Emond
>> >>>
>> >>> On Wednesday 08 February 2012 16:44:14 Martin Grigorov wrote:
>> >>>> On Wed, Feb 8, 2012 at 4:33 PM, Bertrand Guay-Paquet
>> >>>>
>> >>>> <[hidden email]> wrote:
>> >>>>> Hi,
>> >>>>>
>> >>>>> Merging multiple evaluates together will change the scope of some
>> >>>>> variables. The variables in the scope of an evaluate block would
>> carry
>> >>>>> on
>> >>>>> in the following evaluate blocks. This could however be mitigated by
>> >>>>> wrapping each evaluate block in its own function.
>> >>>>
>> >>>> True.
>> >>>> Wrapping them in {} should be enough to prevent this problem.
>> >>>>
>> >>>>> Bertrand
>> >>>>>
>> >>>>> On 08/02/2012 8:24 AM, Martin Grigorov wrote:
>> >>>>>> Hi,
>> >>>>>>
>> >>>>>> Do you imagine a use case in which several<evaluate>s in
>> >>>>>> <ajax-response>  should be executed separately (one after another)
>> as
>> >>>>>> it is now ?
>> >>>>>> Each<evaluate>  (and<priority-evaluate>) is executed in an eval() in
>> >>>>>> wicket-ajax.js. As we all know eval() is slow. As an optimization I
>> >>>>>> think we can merge all<evaluate>s in one (at server side) and eval
>> >>>>>> them all together. The only drawback I see is that error reporting
>> >>>>>> will be worse because the exception message will say "there is an
>> >>>>>> error in 'all JS in one<evaluate>  here' "
>> >
>>



--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
Loading...