[wp-trac] [WordPress Trac] #38911: Prevent Media Library search making an AJAX request for each char typed.

WordPress Trac noreply at wordpress.org
Thu Jan 26 13:41:32 UTC 2017


#38911: Prevent Media Library search making an AJAX request for each char typed.
-------------------------+-------------------------------------------------
 Reporter:               |       Owner:  adamsilverstein
  brandomeniconi         |      Status:  assigned
     Type:  enhancement  |   Milestone:  4.8
 Priority:  normal       |     Version:  4.6.1
Component:  Media        |  Resolution:
 Severity:  normal       |     Focuses:  javascript, administration,
 Keywords:  has-patch    |  performance
  commit                 |
-------------------------+-------------------------------------------------

Comment (by adamsilverstein):

 > Minor thing: do we need the separate `debounceSearch` function? Can we
 just wrap `search` in `_.debounce()` instead?

 Thanks for the feedback @batmoo.

 We probably could just wrap `search` with _.debounce. I like adding the
 `debouncedSearch`method because its name makes it clear the function is
 debounced when you invoke it. Looking thru core for other debounce uses, I
 see we do it a bit both ways - sometimes creating a new named function and
 sometimes wrapping a function directly. I'll give it a try that way, will
 probably make for a smaller diff.

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


More information about the wp-trac mailing list