[wp-trac] [WordPress Trac] #40698: The function wp.emoji.parse is available only after another function is run

WordPress Trac noreply at wordpress.org
Tue May 9 07:44:23 UTC 2017


#40698: The function wp.emoji.parse is available only after another function is run
-----------------------------+-----------------------------
 Reporter:  superpoincare    |      Owner:
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Emoji            |    Version:  4.7.4
 Severity:  normal           |   Keywords:
  Focuses:  javascript       |
-----------------------------+-----------------------------
 I wanted to be able to write a custom Javascript to load wp-emoji-
 release.min.js as soon as possible (say using rel="preload" and/or async)
 and start using the function wp.emoji.parse as soon as possible (such as
 via mutation observer).

 But what's happening is that for the function to work, it needs to run the
 load() function defined in wp-emoji.js

 twemoji has been defined as window.twemoji inside the load function
 https://github.com/WordPress/WordPress/blob/master/wp-includes/js/wp-
 emoji.js#L58

 So using wp.emoji.parse needs to wait till load() is run.

 This can be seen if you see the minified version which has "g.parse"
 instead of twemoji.parse.

 So using wp.emoji.parse(object) early will just return the object instead
 of modifying it.

 Is it possible to make wp.emoji.parse available as soon as possible? I
 think this can be done by moving

 {{{
 twemoji = window.twemoji
 }}}

 outside before the function load() is defined.

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


More information about the wp-trac mailing list