[wp-trac] [WordPress Trac] #58069: Performance of _wp_normalize_relative_css_links() can be increased >2x

WordPress Trac noreply at wordpress.org
Wed Apr 19 01:24:57 UTC 2023


#58069: Performance of _wp_normalize_relative_css_links() can be increased >2x
--------------------------------------+-------------------------------
 Reporter:  westonruter               |       Owner:  westonruter
     Type:  defect (bug)              |      Status:  closed
 Priority:  normal                    |   Milestone:  6.2.1
Component:  Script Loader             |     Version:  5.9
 Severity:  normal                    |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests  |     Focuses:  css, performance
--------------------------------------+-------------------------------
Changes (by westonruter):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"55658" 55658]:
 {{{
 #!CommitTicketReference repository="" revision="55658"
 Script Loader: Optimize performance of
 `_wp_normalize_relative_css_links()` by more than 2x.

 * Replace `preg_match_all()` and its secondary `str_replace()` call with
 `preg_replace_callback()`.
 * Fix case where paths beginning with `http` and `https` (but not `http:`
 and `https:`) were erroneously not counted as relative.
 * Improve code style and readability by consolidating conditions and
 returning once.
 * Use `str_starts_with()` consistently instead of `strpos()`.

 Follow-up to [52036], [52695], and [52754].

 Fixes #58069.
 See #54243.
 }}}

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


More information about the wp-trac mailing list