Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Commented Issue: Parse function in jquery.validate.unobtrusive.js performance improvement [308]

$
0
0
The jquery statement

$(selector).find(":input[data-val=true]").each(....) - line 173 jquery.validate.unobtrusive.js within the Parse(selector) method.

Provides better performance if it is re-written as a chained statement, oppose to as a single selector:
$(selector).find("input").filter["data-val=true]").each(..)

This is because it allows JQuery to use less of the Sizzle engine (which is known to be poor). On a large DOM, it has shown performance improvements of an order of magnitude firing the DOMContentLoaded event.

We have reduced the duration of our Document ready method from 700ms to 300ms.

Thanks,
Comments: I've looked a bit more into this, and i an see why ":input" was used, as it selects all types of input elements on a form Input, textarea, selects etc..., so solely using "Input" isn't viable option. I've done a little editing and added an extra revision to the JSPerf tests Nowakra put together. As a result I've made "FindAll" which gets all the types separately and merges in into a single array. I also created a test to compare selecting the items separately and selecting them via commas. I expect this would be down to the MVC team to decide on how the validation should work, and what should be selected! Cheers (sorry for the bombshell!)

Viewing all articles
Browse latest Browse all 7215

Trending Articles