[wp-trac] [WordPress Trac] #31701: Emoji: Avoid enqueueing JS by default

WordPress Trac noreply at wordpress.org
Mon Mar 23 06:53:56 UTC 2015


#31701: Emoji: Avoid enqueueing JS by default
-----------------------------+--------------------------------------
 Reporter:  obenland         |       Owner:
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  4.2
Component:  General          |     Version:  trunk
 Severity:  major            |  Resolution:
 Keywords:  emoji has-patch  |     Focuses:  javascript, performance
-----------------------------+--------------------------------------

Comment (by pento):

 [attachment:31701.8.diff] has a fun little change.

 As of [attachment:31701.7.diff], the `wp-emoji-loader.js` JavaScript took
 about 15ms to run - 1.5ms for the JS, and 13.5ms for a style
 recalculation, which is caused by our use of `canvas`. I've been
 experimenting a bit, but it seems that the style recalculation is
 unavoidable.

 To fix this, [attachment:31701.8.diff] moves the JS to be embedded before
 `wp_print_styles`. Now the JS takes 1.6ms to run - 1.5ms for the JS, and
 0.1ms for the style recalculation.

 So, now the total is:

 - Running `wp-emoji-loader.js`: 1.6ms
 - Parsing the embedded emoji CSS: <0.1ms

 If we need to load Twemoji:

 - Parsing twemoji.js: 0.8ms
 - Parsing and running wp-emoji.js with no emoji: 1ms

 The overhead if no emoji exists (and we need to load the extra JS) is
 about 3.5ms. About 0.01ms is added per emoji replaced. I haven't timed
 this with the built scripts yet, but I expect everything to be slightly
 faster.

 @wonderboymusic - given your earlier feelings on running this every time,
 what's your opinion now on a 1.7-3.5ms overhead?

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


More information about the wp-trac mailing list