[wp-trac] [WordPress Trac] #27034: jQuery methods html('') vs empty()

WordPress Trac noreply at wordpress.org
Thu Feb 6 09:49:11 UTC 2014


#27034: jQuery methods html('') vs empty()
-----------------------------+--------------------------------------
 Reporter:  madeinua         |       Owner:
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Administration   |     Version:  3.8.1
 Severity:  normal           |  Resolution:
 Keywords:                   |     Focuses:  javascript, performance
-----------------------------+--------------------------------------
Changes (by TobiasBg):

 * component:  Appearance => Administration


Old description:

> I found that in a many places in WP uses .html('') instead of .empty()
>
> There is a few advantages to use the second one:
>
> 1. $.empty() works faster
> 2. $.html('') creates memory leak
> 3. $.empty() is more readable
>
> Confirmation of these words you can find on the internet (e.g.
> stackoverflow).
>
> Thanks!

New description:

 I found that in a many places in WP uses `.html('')` instead of `.empty()`

 There is a few advantages to use the second one:

 1. `$.empty()` works faster
 2. `$.html('')` creates memory leak
 3. `$.empty()` is more readable

 Confirmation of these words you can find on the internet (e.g.
 stackoverflow).

 Thanks!

--

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27034#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list