No idea about the performance drop, but you can improve your main function:
// MAIN function getMenuItems(menu) { var menuItems = []; $(menu).find('.MenuItem').each(function(){ var t = $(this), item = false; if (t.hasClass('processMenuItem')) item = getProcessMenuItem (this); else if (t.hasClass('softwareMenuItem')) item = getSoftwareMenuItem(this); else if (t.hasClass('listMenuItem')) item = getListMenuItem (this); else if (t.hasClass('aboutMenuItem')) item = getAboutMenuItem (this); item = t.hasClass('processMenuItem') ? getProcessMenuItem(this) : t.hasClass('softwareMenuItem') ? getSoftwareMenuItem(this) : t.hasClass('listMenuItem') ? getListMenuItem(this) : t.hasClass('aboutMenuItem') ? getAboutMenuItem(this) : false; menuItems.push(item); }); return menuItems; }; On Feb 19, 4:18 pm, Sjoland <jo...@sjoland.com> wrote: > Hi!, > > When switching between 1.3.1 and 1.2.6 i get a serious drop in speed > when collection a JSON object from static HTML content. > > 1.2.6 > FF: 325ms > Safari: 75ms > IE7: 450ms > > 1.3.1 > FF: 1205ms > Safari: 415ms > IE7: 1550 ms > > The javascript collects data into a JSON object with a few methods > like this: > > // MAIN > function getMenuItems(menu) { > var menuItems = []; > $(menu).find('.MenuItem').each(function(){ > var item = false; > if ($(this).hasClass('processMenuItem')) item = > getProcessMenuItem($ > (this)[0]); > if ($(this).hasClass('softwareMenuItem')) item = > getSoftwareMenuItem > ($(this)[0]); > if ($(this).hasClass('listMenuItem')) item = > getListMenuItem($(this) > [0]); > if ($(this).hasClass('aboutMenuItem')) item = > getAboutMenuItem($ > (this)[0]); > menuItems.push(item); > }); > return menuItems; > > }; > > // COLLECTOR > function getProcessMenuItem(li) { > var type = "processMenuItem"; > var item = { > "id" : $(li).attr('id'), > "type" : type, > "title" : $(li).find('a:first').text(), > "URI": $(li).find('a:first').attr('href'), > "preamble" : $(li).find('li.Intro h4').text(), > "body" : $(li).find('li.Intro p').text(), > "news" : { > "title" : $(li).find('li.News a').text(), > "URI" : $(li).find('li.News a').attr('href'), > "summary" : $(li).find('li.News a').attr('title') > }, > "splash" : { > "title" : $(li).find('li.Splash a').text(), > "URI" : $(li).find('li.Splash a').attr('href'), > "summary" : $(li).find('li.Splash a').attr('title'), > "media" : $(li).find('li.Splash img').attr('src') > }, > "links" : getAnchorLinks(li) > }; > return item; > > }; > > Anyone else experiencing drops in speed with 1.3.1 doing simple stuff > like this? > Sure, I was not expecting any major speed increase since the code is > not optimized yet, but an 80% drop is just crazy... > > Please advice, > /Johan