[wp-trac] [WordPress Trac] #32197: Twemoji script and editor expansion combo making editor ridiculously slow in some circumstances

WordPress Trac noreply at wordpress.org
Wed Apr 29 22:40:51 UTC 2015


#32197: Twemoji script and editor expansion combo making editor ridiculously slow
in some circumstances
--------------------------+-----------------------------
 Reporter:  Otto42        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  TinyMCE       |    Version:  4.2
 Severity:  major         |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Original report on the forum:
 https://wordpress.org/support/topic/text-editor-extremely-slow

 I was finally able to reproduce this one. The issue occurs when you have
 these circumstances:

 1. A really long post. I found that about 60000 characters of Lorem Ipsum
 showcases it quite well.

 2. Use the Text editor. The Visual editor largely seems unaffected. Not
 sure why.

 3. The "Enable full-height editor and distraction-free functionality."
 must be enabled.

 When these conditions are met, every interaction with the textarea,
 clicks, typing characters, just about anything, gets picked up by the
 MutationObserver in wp-emoji.js, passed through parse(), and eventually
 into parseNode() in the twemoji.js.

 Since the node in question is the textarea, it runs that big ugly 10000
 byte regular expression across the entirety of the post content... on
 every keypress or other interaction with the textarea.

 Different browsers handle this differently.

 Chrome on Windows 8 doesn't seem to care much (fast JS indeed) until there
 is a 2-byte character anywhere in the post. The easiest way to trigger the
 lag is by inserting a copy/pasted "smart quote" into the post. U+201C
 works. This makes the re.exec() in twemoji.js go from a 80ms run to 1.5s
 or so.

 Firefox on Windows 8 shows a noticable amount of lag regardless. The
 amount seems to correlate with the size of the post content.

 Note that either disabling wp-emoji.js or turning off the editor-expand in
 the Screen Options will "fix" the problem for the short term.

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


More information about the wp-trac mailing list