[wp-trac] [WordPress Trac] #37788: dns-prefetch s.w.org conditionally via javascript

WordPress Trac noreply at wordpress.org
Fri Nov 12 02:33:01 UTC 2021


#37788: dns-prefetch s.w.org conditionally via javascript
---------------------------+------------------------------
 Reporter:  superpoincare  |       Owner:  (none)
     Type:  enhancement    |      Status:  new
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Script Loader  |     Version:  4.6
 Severity:  normal         |  Resolution:
 Keywords:                 |     Focuses:  performance
---------------------------+------------------------------
Changes (by westonruter):

 * focuses:   => performance


Comment:

 We should consider doing more detection for whether to print emoji
 detection script as well. Not only is the `dns-prefetch` to `s.w.org`
 potentially a wasted connection, if a page lacks any emoji then the emoji
 detection script causes a long task.

 For example, at https://pento.net/2021/01/21/wordpress-importers-free-as-
 in-speech/ see the above screenshot for the long task that
 `print_emoji_detection_script()` causes. If this script were removed,
 ~90ms could be shaved off of page load time. Also removing a needless
 `dns-prefetch` would improve things yet more.

 There is prior discussion in #37817, but it it was about about improving
 the emoji detection script not detecting whether emoji is present. It's
 difficult to do this emoji detection in a traditional theme without using
 output buffering, since it's not known in the `head` what the `body` will
 include (other than looking at the main query). However, with full site
 editing this may indeed be doable as the entire page would be rendered as
 blocks and be in memory prior to printing. In this way, the blocks could
 be inspected for whether or not they contain emoji server-side, and only
 then print the `dns-prefetch` link to `s.w.org` and the emoji detection
 script.

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


More information about the wp-trac mailing list