mootools / slick

Standalone CSS Selector Parser and Engine. An official MooTools project.
MIT License
149 stars 22 forks source link

Faster context switch (setDocument) #13

Open Inviz opened 13 years ago

Inviz commented 13 years ago

I'm facing rather rare problem, because people dont use slick too much outside of DOM.

Slick is too slow when switching between documents, because it calculates the quirks every time document is set. So if you have more than one document to use with one Slick instance, it could just memoize the quirks once in an object and store it in document itself or in UID-based storage, whatever.

When using another DOM tree, i'm happy using XML-emulation. But it does not give me an option of which function to choose for UID calculation. It uses getUIDXML that uses attribute getters and setters which may be expensive for virtual nodes that use attributes for something valuable.

If you think that you dont have time for this but you consider this a good idea, then I'll find time to do it.

fabiomcosta commented 13 years ago

Yeah we could cache the document by its UID, ill try this right now.

fabiomcosta commented 13 years ago

Hmm i couldnt find the best way to do this. Im focusing on the html5 elements but next is this one.

Inviz commented 13 years ago

http://jsfiddle.net/UQfu4/ Here is an example of worst case (but still real life) scenario where context switch takes 95% execution time.

Here is a screenshot of a profile: https://img.skitch.com/20110220-xph4wueeu84fps3k9a1w9uhx93.png