Bug Tracker

Opened 13 years ago

Closed 13 years ago

#6216 closed enhancement (duplicate)

[Patch] Drop-in replacement for jQuery's trim() function

Reported by: mgruner Owned by:
Priority: Milestone: 1.4.3
Component: misc Version: 1.4.2
Keywords: patch, trim, speed, performance, optimization Cc: [email protected]
Blocked by: Blocking:


Inspired by http://blog.stevenlevithan.com/archives/faster-trim-javascript, I developed a trim() function that is just a little slower than the current, regexp-replacement based solution in jQuery 1.4.2 for very short strings (< 50 characters). It is, however, MUCH faster for longer and very long strings. Depending on the browser, the speed improvement compared to the current implementation can be several orders of magnitude. Please see the attached patch.

Best regards and wishes for the success of jQuery, Martin Gruner

Attachments (1)

jquery-optimized-trim.patch (777 bytes) - added by mgruner 13 years ago.
Optimized trim function for jQuery

Download all attachments as: .zip

Change History (2)

Changed 13 years ago by mgruner

Attachment: jquery-optimized-trim.patch added

Optimized trim function for jQuery

comment:1 Changed 13 years ago by john

Resolution: duplicate
Status: newclosed

Duplicate of #2279.

Note: See TracTickets for help on using tickets.