Opened 9 years ago
Closed 4 years ago
#40698 closed feature request (invalid)
The function wp.emoji.parse is available only after another function is run
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 4.7.4 |
| Component: | Emoji | Keywords: | reporter-feedback |
| Focuses: | javascript | Cc: |
Description
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.
Change History (2)
#2
@
4 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
Closing this due to lack of activity / response, but if someone (@superpoincare like you ;) has additional information to provide then please re-open this for further discussion and agreement on approach... thanks!
Twemoji needs to be loaded for
wp.emoji.parse()to work, hence whyload()waits forwindow.twemojito be defined before continuing.Can you give a more clearly defined example of why you need to use
parse()earlier than whenload()runs?