Why does passing in options slow down my code so much?
I'm working on the fasterTrim plug-in and I'm wondering why passing in custom options slows it down so much.
Here's a comparison of
running the function as many times as possible in 1000ms to show what I mean:
- $.fasterTrim.trim( " lorem ipsum " )
vs:
- $.fasterTrim.trim( " lorem ipsum ", {} )
* Firefox 3.6: 170,232 vs 46,147
* IE 8: 69,371 vs 25,226
* Chrome 4.1: 837,572 vs 56,073
* Safari 4.0.4: 172,995 vs 82,950
* Opera 10.10: 67,934 vs 32,938Does the code to process the options add that much overhead?
- options = jQuery.extend( {}, jQuery.fasterTrim.defaultOptions, options );
Links:
plugin ,
source ,
demo ,
previous discussion .
--Travis