[wp-trac] [WordPress Trac] #57517: Expose MutationObserver instance in wpEmoji

WordPress Trac noreply at wordpress.org
Fri Jan 20 19:30:38 UTC 2023


#57517: Expose MutationObserver instance in wpEmoji
-----------------------------------------+-----------------------------
 Reporter:  rinatkhaziev                 |      Owner:  (none)
     Type:  enhancement                  |     Status:  new
 Priority:  normal                       |  Milestone:  Awaiting Review
Component:  Formatting                   |    Version:
 Severity:  normal                       |   Keywords:
  Focuses:  ui, javascript, performance  |
-----------------------------------------+-----------------------------
 The current implementation of MutationObserver in wpEmoji keeps the
 instance private, making it impossible to disconnect/reconnect the
 observer if necessary.

 This has performance implications whenever a page performs large/complex
 DOM updates frequently.

 A typical workaround is to disable wpEmoji altogether, but I believe
 there's a better way.

 If we expose the observer instance, we can call connect/disconnect as
 needed.


 {{{#!javascript

 // Before doing something expensive
 wp.emoji.getObserver().disconnect();

 // render 10k nodes in your favorite frontend framework

 // Re-enable later
 wp.emoji.getObserver().observe( document.body, {
         childList: true,
         subtree: true
 } )
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57517>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list