Changes between Version 3 and Version 4 of Ticket #58069
- Timestamp:
- 04/05/2023 01:59:34 PM (21 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #58069 – Description
v3 v4 1 1 The `_wp_normalize_relative_css_links()` function is not currently implemented in an optimal way. It is doing a regex match for all instances of `url(...)` in a given CSS, and then for each match it checks if it is a relative URL. If so, it then makes the URL absolute and then does ''another'' global search & replace in the CSS to replace the relative path with the absolute path. This means for every search there is a secondary search. This secondary `str_replace()` can be eliminated by replacing the unitial `preg_match_all()` with a `preg_replace_callback()`. This makes the function run >2x faster when [https://gist.github.com/westonruter/7f916bee3f45ef9307235daefb603e7c benchmarked] being run across each CSS file in Gutenberg and the built-in themes. 2 3 Essentially the function can be turned from O(n²) to O(n).4 2 5 3