Modify ↓
Ticket #4407 (closed enhancement: worksforme)
Empty selectbox
| Reported by: | Jorik | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.3.2 |
| Component: | core | Version: | 1.3.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
The empty() method on a selectbox is _much_ slower then selectbox.options.length = 0; Maybe it is nice to check if the element is a selectbox, and then use the options.length way to empty the selectbox.
Attachments
Change History
comment:4 Changed 3 years ago by dmethvin
- Keywords needsreview added
- Status changed from new to open
We still need to clean off the data attributes. I can't get the test case to work though.
comment:5 Changed 2 years ago by dmethvin
- Status changed from open to closed
- Resolution set to worksforme
The differences don't seem that large to me; I even increased the number of options. For cases where someone is updating large numbers selects at a high frequency and is willing to risk the memory leaks, they can set options.length=0.
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.


I tested whats faster; the build-in jQuery technick of a while loop and your suggestion of length=0 Aldo your suggestion is faster then the while loop, it's not the while loop that slows it down; it's the expando management that is the 'problem'.