Forgive me, if this is a recurring argument.
Today I was looking at Firebug profiler and I realize that
getElementsByTagAndClassName takes certain percentages of processing
time. And I took a look at the code, and I did a little bit of hand
optimization. It doesn't change any semantics of code, but just
organizing code. It does pass the tests of course. And i got around
6% better performance.
Well the down side of this tweak may be the decrease of readability.
Since you need to carefully type comma between local variables. I
usually check it with jslint before commit in order to find those
potential mistakes. And obviously I don't much about coding
convention of MochiKit and I might need to edit the style of it.
Here I attached .patch file for this issue. Please try it and let me
know what you think. if somebody's interested in, I can contribute
some more performance tweaks in MochiKit.
Thanks,
--
Takashi M
>
> I created a getElementsByClassName based on this code:
> http://robertnyman.com/2008/05/27/the-ultimate-getelementsbyclassname-anno-2008/
> http://code.google.com/p/getelementsbyclassname/
>
> Pending a full selector integration something like this should be an
> easy drop-in
> solution to optimize getElementsByTagAndClassName.
> (IE really needs some speedup here..)
>
> // Fredrik Blomqvist
>
> On Nov 5, 7:45 am, Amit Mendapara <mendapara.a...@gmail.com> wrote:
>> Look at my mochikit-ext project athttps://launchpad.net/mochikit-ext.
>> I have implemented a jQuery style API in MochiKit.Query module
>> (http://
>> bazaar.launchpad.net/~amit-mendapara/mochikit-ext/trunk/files) which
>> is based on Sizzle.js (http://github.com/jeresig/sizzle).
>>
>> MochiKit.DOM.getElementsByTagAndClassName("div", "some-class")
>>
>> can be replaced with
>>
>> MochiKit.Query("div.some-class").get()
>>
>> The Sizzle.js is the fastest selector engine out there. Seehttp://www.hvergi.net/arnar/public/sizzle/speed/#for
>> the speed tests.
Actually, it's not. The Acme engine in Dojo beats it by a fair bit on
most real-world selectors. It's stand-alone and can be easily imported
(like Sizzle).
Regards