A lot has changed with regard to the selector engine in 1.3.1 - it
this case it looks like these type of selections didn't benefit. One
thing that would change that, though, would be caching the selectors
that you do run. Right now you run a couple of these over-and-over
again. I'd probably rewrite your method like this:
// COLLECTOR
function getProcessMenuItem(li) {
       var type = "processMenuItem";
       var first = $(li).find('a:first'),
            news = $(li).find('li.News > a'),
            splash = $(li).find('li.Splash > a');

       var item = {
               "id" : $(li).attr('id'),
               "type" : type,
               "title" : first.text(),
               "URI": first.attr('href'),
               "preamble" : $(li).find('h4').text(),
               "body" : $(li).find('p').text(),
               "news" : {
                       "title" : news.text(),
                       "URI" : news.attr('href'),
                       "summary" : news.attr('title')
               },
               "splash" : {
                       "title" : splash.text(),
                       "URI" : splash.attr('href'),
                       "summary" : splash.attr('title'),
                       "media" : splash.next().attr('src')
               },
               "links" :  getAnchorLinks(li)
       };
       return item;
};

I'm not sure what's in your getAnchorLinks method - but that could
probably be optimized as well.

--John



On Fri, Feb 20, 2009 at 5:02 AM, Sjoland <jo...@sjoland.com> wrote:
>
> The markup look like this:
>
> <li class="MenuItem processMenuItem" id="MENUID-D">
> <a href="processing/x/">X<br>Processing</a>
> <ul>
> <li class="Intro">
> <h4>If you recieve 20,000 invoices per year, you can save at least
> $100,000</h4>
> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
> eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
> </li>
> <li class="News Disabled">
> <a href="processing/x/news/" title="News summary.">News text...</a>
> </li>
> <li class="Splash Disabled">
> <a href="processing/x/splash/" title="Splash summary.">Splash text...</
> a>
> <img src="media/splashImage.jpg">
> </li>
> <li class="Anchor"><a href="processing/x/#Overview">Overview</a></li>
> <li class="Anchor"><a href="processing/x/#Introduction" title="We are
> experts in sorting.">Introduction</a></li>
> <li class="Anchor"><a href="processing/x/#Article">Article</a></li>
> <li class="Anchor"><a href="processing/x/#Features">Features</a></li>
> <li class="Anchor"><a href="processing/x/#References" title="IKEA,
> Porsche, Pfizer, SAS, Tetra Pak, Carlsberg, DaimlerChrysler, LEGO,
> Bosch, DFDS transport, Canon...">References</a></li>
> <li class="Anchor"><a href="processing/x/#Technical">Technical</a></
> li>
> <li class="Anchor"><a href="processing/x/#Integration" title="Lorem
> ipsum dolor sit amet.">Integration</a></li>
> <li class="Anchor"><a href="processing/x/#Downloads">Downloads</a></
> li>
> </ul>
> </li>
>
> The timer looks like this:
> var timer = {
>        time: 0,
>        now: function(){ return (new Date()).getTime(); },
>        start: function(){ this.time = this.now(); },
>        since: function(){ return this.now()-this.time; }
> };
>
> ...and I start the timer in the last row of the last script being
> loaded...
>
> Yes, I know there are many ways to improve and optimize my methods,
> BUT that's not my main issue right now, becuse any improvment like the
> one Ricardobeat suggests still ends up with less speed in 1.3.1 vs
> 1.2.6.
>
> Thanks,
> /Johan

Reply via email to