Modify ↓
Ticket #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: | marc.nilius@… |
| Blocking: | Blocked by: |
Description
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
Change History
Changed 3 years ago by mgruner
-
attachment
jquery-optimized-trim.patch
added
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

Optimized trim function for jQuery