jQuery performance in IE7

Antranig Basman antranig at caret.cam.ac.uk
Wed Jan 28 16:26:23 UTC 2009


Whilst that is a useful optimisation on IE family browsers, be
aware that it will in general lead to somewhat poorer performance
on Firefox and others - these have a special optimisation for
string concatenation using += which feeds through fairly directly
to what looks like a "realloc" call in the underlying implementation.

Beware "optimisations bearing gifts" :P

Cheers,
A.


> J.Fine wrote:
> 
> Hello Lovemore
> 
> 
> 
> Here’s how you’ve constructed a string.
> 
> 
> 
>                         var params = 'item-text=' + itemText;
> 
>                         params += '&item-text-fossil=istring%23%7BtemplateItemWBL.new1.item.itemText%7D';
> 
>                         params += '&showItemCategory%3A%3Aitem-category-list-selection-fossil=istring%23%7BtemplateItemWBL.new1.category%7DCourse';
> 
>                         params += '$showItemCategory%3A%3Aitem-category-list-selection=' + category;
> 
>                         params += '&idealColor-fossil=iboolean%23%7BtemplateBBean.idealColor%7Dfalse';
> 
>                         params += '&idealColor=' + idealColour;
> 
>                         params += '&item_NA-fossil=iboolean%23%7BtemplateItemWBL.new1.usesNA%7Dfalse';
> 
>                         params += '&item_NA=' + usesNA;
> 
>                         var ordering = new Array();
> 
>                         ui.item.parents('.itemTableBlock').eq(0).children('.itemRowBlock').filter(':visible').each(function() {
> 
>                             var val = $(this).children('input[name=hidden-item-id]').eq(0).val();
> 
>                             params += '&hidden-item-id=' + val;
> 
>                             ordering.push(val);
> 
>                         });
> 
>                         params += '&templateItemIds=' + ordering.toString();
> 
>                         params += '&ordered-child-ids=' + ordering.toString();
> 
>                         params += '&ordered-child-ids-fossil=istring%23%7BtemplateBBean.orderedChildIds%7D';
> 
>                         params += '&templateId=' + t.attr('templateid');
> 
>                         params += '&command+link+parameters%26el-binding%3Dj%2523%257BtemplateBBean.blockId%257Dnew1%26el-binding%3Dj%2523%257BtemplateBBean.templateItemIds%257D' + ordering.toString() + '%26el-binding%3Dj%2523%257BtemplateBBean.originalDisplayOrder%257D2%26Submitting%2520control%3DsaveBlockAction%26Fast%2520track%2520action%3DtemplateBBean.saveBlockItemAction=Save+item';
> 
> 
> 
> 
> 
> Here’s a quicker way to do the same sort of thing
> 
> 
> 
> // Top level.
> 
> var template = ['xxx', 0, 'yyy', 1, 'zzz', 2, 'etc'];
> 
> 
> 
>     // In loop.
> 
>     template[1] = 'wibble';
> 
>     template[3] = 'wobble';
> 
>     template[5] = 'foozle';
> 
>     var value template.join('');
> 
> 
> 
> There are other things you might try, but I think this would be a good start.
> 
> 
> 
> 
> 
> Jonathan
> 
> 
> 
> 
> 
> 
> 
> ----------------------------------------------------------------------------------------
> 
> From: fluid-talk-bounces at fluidproject.org [mailto:fluid-talk-bounces at fluidproject.org]
> On Behalf Of Lovemore Nalube
> Sent: 28 January 2009 07:29
> To: Colin Clark
> Cc: fluid-talk at fluidproject.org
> Subject: Re: jQuery performance in IE7
> 
> 
> 
> Hey Colin,
> 
> Here's the actual code:
> https://source.sakaiproject.org/contrib/uct/evaluation-pilot08-UI/tool/src/webapp/content/js/reorderUtils.js.
> 
> ************************
> Lovemore Nalube
> Online Learning Environments Developer
> Centre for Educational Technology
> University of Cape Town
> www.cet.uct.ac.za
> 
> /* Work Email: lovemore.nalube at uct.ac.za
> /* Cell: 076 186 1244
> /* GTalk: lovenalube at gmail.com
> 
> On Tue, Jan 27, 2009 at 6:28 PM, Colin Clark <colin.clark at utoronto.ca> wrote:
> 
> Lovemore,
> 
> On 27-Jan-09, at 2:15 AM, Lovemore Nalube wrote:
> 
> I've reached a stage in which the preliminary phase nears completion, however when
> testing the UI in IE7, there is a huge performance overhead. FF3 seems to hold the load
> quite easily. In a nutshell what freezes the browser is trying to filter through a
> response object to get elements that exist within and then show these on the UI. Has
> anyone ever had issues with jQuery performance/freezing the browser like this?
> 
> I invite you to checkout the code at
> https://source.sakaiproject.org/contrib/uct/evaluation-pilot08-UI. The page with the new
> UI is Evaluations dashboard > My Templates > Edit Template
> 
> 
> 
> Do you have a link to the specific JavaScript source code that you're seeing the problem
> in? We can probably lend a hand in optimizing your implementation.
> 
> Colin
> 
> ---
> Colin Clark
> Technical Lead, Fluid Project
> Adaptive Technology Resource Centre, University of Toronto
> http://fluidproject.org
> 
> 
> 
> 
> 
> ---------------------------------
> The Open University is incorporated by Royal Charter (RC 000391), an exempt charity in
> England & Wales and a charity registered in Scotland (SC 038302).
> 
>     --------------------------------------------------------------------------------
> _______________________________________________________
> fluid-talk mailing list - fluid-talk at fluidproject.org
> To unsubscribe, change settings or access archives,
> see http://fluidproject.org/mailman/listinfo/fluid-talk



More information about the fluid-talk mailing list