Here's a patch for a faster version of jQuery.trim based on native String.trim and these improvements: http://blog.stevenlevithan.com/archives/faster-trim-javascript
Test case: http://jsbin.com/oquji/2
Patch:
(removed)
I also just requested a pull request.
The native String.trim is ridiculously fast.