#58892 closed enhancement (fixed)
Integrate `decoding="async"` logic into `wp_get_loading_optimization_attributes()`
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Media | Keywords: | has-patch, has-unit-tests, has-dev-note |
Focuses: | performance | Cc: |
Description
The wp_get_loading_optimization_attributes()
function was added in WordPress 6.3 as a central way to apply loading attributes to specific elements/tags. One of the attributes that WordPress core has supported since 6.1 (see #53232) is decoding="async"
. This attribute is currently still manually applied, instead it should be applied as part of the new function going forward.
This ticket's implementation should be considered blocked by #58891 as making the changes before that would be unnecessarily complicated and error-prone.
Attachments (1)
Change History (30)
This ticket was mentioned in PR #4991 on WordPress/wordpress-develop by @pereirinha.
19 months ago
#3
- Keywords has-patch has-unit-tests added
## What's in:
- [x] Moved the
decoding
attribute of theimg
tag intowp_get_loading_optimization_attributes()
; - [x] Deprecation of
wp_img_tag_add_decoding_attr()
and it's filters; - [x] Add and update tests relevant to the ticket
Trac ticket: 58892
@mukesh27 commented on PR #4991:
18 months ago
#4
Have you get decoding
attribute in content images?
#5
@
18 months ago
- Keywords changes-requested added
Thanks @pereirinha for the PR. It's a great beginning. I've provided some feedback that you might want to take into account.
@pereirinha commented on PR #4991:
18 months ago
#6
@mukeshpanchal27 @joemcgill
Thanks for your comments. I'm actively working on them and pushing updates frequently.
I'll comment when I'm done so you can circle back on this.
@pereirinha commented on PR #4991:
18 months ago
#7
Thank you all for the feedback. I'll be working on it.
@pereirinha commented on PR #4991:
18 months ago
#8
Thanks, @mukeshpanchal27 @joemcgill @felixarntz, for all the comments so far.
I left you some comments back, where it made sense, and updated the code. There are still some pieces I'm trying to wrap my head around, and a quick call would be very helpful to clear them.
If it makes sense, let's talk on Slack and try to conciliate a time for it.
This ticket was mentioned in Slack in #core-performance by pereirinha. View the logs.
18 months ago
This ticket was mentioned in Slack in #core-performance by pereirinha. View the logs.
17 months ago
This ticket was mentioned in Slack in #core-performance by flixos90. View the logs.
17 months ago
This ticket was mentioned in Slack in #core-performance by flixos90. View the logs.
17 months ago
#13
@
17 months ago
- Keywords needs-dev-note added
The 4 tickets related to wp_get_loading_optimization_attributes()
should receive a single dev note post explaining those changes.
This ticket was mentioned in Slack in #core by oglekler. View the logs.
17 months ago
This ticket was mentioned in Slack in #core-performance by pereirinha. View the logs.
17 months ago
@flixos90 commented on PR #4991:
17 months ago
#17
Committed in https://core.trac.wordpress.org/changeset/56690
#19
@
17 months ago
- Resolution fixed deleted
- Status changed from closed to reopened
Reopenning, as this commit resulted in a notice error. See attached screenshot.
This ticket was mentioned in Slack in #core-performance by spacedmonkey. View the logs.
17 months ago
This ticket was mentioned in PR #5331 on WordPress/wordpress-develop by @pereirinha.
17 months ago
#21
This PR fixes a regression introduced on #58892 when moving the responsibility for the decoding
attribute to the wp_get_loading_optimization_attributes
.
This will add the decoding
attribute to the get_avatar()
. As trunk currently is, this context will fail to get any optimization attributes while running the_content
filter.
Trac ticket: #58892
This ticket was mentioned in PR #5331 on WordPress/wordpress-develop by @pereirinha.
17 months ago
#22
This PR fixes a regression introduced on #58892 when moving the responsibility for the decoding
attribute to the wp_get_loading_optimization_attributes
.
This will add the decoding
attribute to the get_avatar()
. As trunk currently is, this context will fail to get any optimization attributes while running the_content
filter.
Trac ticket: #58892
#23
@
17 months ago
This Slack thread holds more information about the reopening and discussion around the source of the issue and mitigatory measures.
In sum, there's a regression introduced here https://github.com/WordPress/wordpress-develop/pull/4991/commits/828130034c5a7790ed8e53660b34eeaf214b4e0d#diff-2dd87d67e80339[…]3df894da4462e69L2848/, where the default value for decoding was removed.
As you see, I also removed it in various other places, and I wasn't able to get any issues. The reason for that is that we get the decoding attribute via the wp_get_loading_optimization_attributes() that we ran after.
The problem with the gravatar is that it is requested within the context of get_avatar, but when we are doing the the_content filter. This will fail this check so we end up without the decoding attribute.
The recommendation is to bring the decoding attribute as a default value as it was for the get_avatar(), but I don't think we need to bring the other ones.
An alternative approach suggested by @spacedmonkey is to move the setting of the decoding
attribute before the context checks, as this argument has a different type of impact than lazy loading and fetchpriority.
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
17 months ago
This ticket was mentioned in Slack in #core-performance by mukeshpanchal27. View the logs.
17 months ago
@pereirinha commented on PR #5331:
17 months ago
#26
@felixarntz @mukeshpanchal27
I made the change and didn't find any issues.
@flixos90 commented on PR #5331:
17 months ago
#28
Committed in https://core.trac.wordpress.org/changeset/56756
With [56347] committed, this effort is now unblocked. Please refer to the latest codebase for any changes to
wp_get_loading_optimization_attributes()
.