[wp-trac] [WordPress Trac] #58891: Simplify logic in `wp_get_loading_optimization_attributes()`
WordPress Trac
noreply at wordpress.org
Wed Aug 2 17:56:32 UTC 2023
#58891: Simplify logic in `wp_get_loading_optimization_attributes()`
--------------------------------------+--------------------------
Reporter: flixos90 | Owner: flixos90
Type: enhancement | Status: closed
Priority: normal | Milestone: 6.4
Component: Media | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests | Focuses: performance
--------------------------------------+--------------------------
Changes (by flixos90):
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"56347" 56347]:
{{{
#!CommitTicketReference repository="" revision="56347"
Media: Simplify logic in `wp_get_loading_optimization_attributes()`.
While the `wp_get_loading_optimization_attributes()` function was only
recently introduced in 6.3, its code was mostly ported over from the now
deprecated `wp_get_loading_attr_default()` function introduced in 5.5.
That function started out in a simple way, but over time was expanded with
more and more conditionals on when to avoid lazy-loading, which ended up
making the logic extremely complex and hard to follow.
This changeset refactors the logic to simplify it, in a way that allows to
follow it more sequentially, and without making any functional changes,
ensuring that the extensive existing unit test coverage still passes. This
will facilitate future enhancements to the function to be less error-prone
and make it more accessible to new contributors.
Props flixos90, joemcgill.
Fixes #58891.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58891#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list