Skip to content

Add fetchpriority=low to IMG tags in collapsed Accordion Item blocks#76336

Merged
westonruter merged 2 commits intotrunkfrom
add/fetchpriority-low-img-in-collapsed-accordion-item
Mar 10, 2026
Merged

Add fetchpriority=low to IMG tags in collapsed Accordion Item blocks#76336
westonruter merged 2 commits intotrunkfrom
add/fetchpriority-low-img-in-collapsed-accordion-item

Conversation

@westonruter
Copy link
Copy Markdown
Member

What?

Fixes #76335

Given the following, where the initial Accordion Item is collapsed by default (as is the default) but the second is expanded by default:

Sample Post Content
<!-- wp:accordion -->
<div role="group" class="wp-block-accordion"><!-- wp:accordion-item -->
<div class="wp-block-accordion-item"><!-- wp:accordion-heading -->
<h3 class="wp-block-accordion-heading"><button type="button" class="wp-block-accordion-heading__toggle"><span class="wp-block-accordion-heading__toggle-title">First Image</span><span class="wp-block-accordion-heading__toggle-icon" aria-hidden="true">+</span></button></h3>
<!-- /wp:accordion-heading -->

<!-- wp:accordion-panel -->
<div role="region" class="wp-block-accordion-panel"><!-- wp:image {"id":36,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="http://localhost:8000/wp-content/uploads/2025/11/American_bison_k5680-1-1024x668.jpg" alt="" class="wp-image-36"/></figure>
<!-- /wp:image --></div>
<!-- /wp:accordion-panel --></div>
<!-- /wp:accordion-item -->

<!-- wp:accordion-item {"openByDefault":true} -->
<div class="wp-block-accordion-item is-open"><!-- wp:accordion-heading -->
<h3 class="wp-block-accordion-heading"><button type="button" class="wp-block-accordion-heading__toggle"><span class="wp-block-accordion-heading__toggle-title">Second Image</span><span class="wp-block-accordion-heading__toggle-icon" aria-hidden="true">+</span></button></h3>
<!-- /wp:accordion-heading -->

<!-- wp:accordion-panel -->
<div role="region" class="wp-block-accordion-panel"><!-- wp:image {"id":37,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="http://localhost:8000/wp-content/uploads/2025/11/Bison_with_its_young-2560w-1024x683.jpg" alt="" class="wp-image-37"/></figure>
<!-- /wp:image --></div>
<!-- /wp:accordion-panel --></div>
<!-- /wp:accordion-item --></div>
<!-- /wp:accordion -->

The diff on the rendered HTML with this PR:

--- before.html	2026-03-09 21:16:42
+++ after.html	2026-03-09 21:17:17
@@ -40,10 +40,10 @@
     >
       <figure class="wp-block-image size-large">
         <img
-          fetchpriority="high"
           decoding="async"
           width="1024"
           height="668"
+          fetchpriority="low"
           sizes="(max-width: 645px) 100vw, 645px"
           src="http://localhost:8000/wp-content/uploads/2025/11/American_bison_k5680-1-1024x668.jpg"
           alt=""
@@ -96,6 +96,7 @@
     >
       <figure class="wp-block-image size-large">
         <img
+          fetchpriority="high"
           decoding="async"
           width="1024"
           height="683"

This is a follow-up to:

Why?

Images which are hidden from view should never get fetchpriority=high. They should instead get fetchpriority=low to prevent adding network contention to actual resources in the critical rendering path.

How?

The existing block_core_accordion_item_render() function is amended to set fetchpriority=low on all IMG tags when openByDefault is false.

Testing Instructions

See testing instructions on the issue:

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 10, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: westonruter <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: im3dabasia <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions bot added the [Package] Block library /packages/block-library label Mar 10, 2026
@westonruter westonruter force-pushed the add/fetchpriority-low-img-in-collapsed-accordion-item branch from 5613166 to 8a52a6b Compare March 10, 2026 04:23
@westonruter westonruter requested review from t-hamano and removed request for ajitbohra and fabiankaegy March 10, 2026 04:24
@westonruter westonruter changed the title Add fetchpriority=low to IMG tags in collapsed Accordion Item blocks Add fetchpriority=low to IMG tags in collapsed Accordion Item blocks Mar 10, 2026
@westonruter westonruter added this to the Gutenberg 22.8 milestone Mar 10, 2026
@github-project-automation github-project-automation bot moved this to 🔎 Needs Review in WordPress 7.0 Editor Tasks Mar 10, 2026
@westonruter westonruter added [Type] Performance Related to performance efforts [Block] Accordion Affects the Accordion Block Backport to WP 7.0 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Mar 10, 2026
@github-actions
Copy link
Copy Markdown

Flaky tests detected in dbb0673.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/22887038555
📝 Reported issues:

Copy link
Copy Markdown
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@im3dabasia
Copy link
Copy Markdown
Contributor

LGTM ✅

trunk this PR
Screenshot 2026-03-10 at 8 15 11 PM Screenshot 2026-03-10 at 8 12 42 PM

@westonruter westonruter merged commit 50a3fc5 into trunk Mar 10, 2026
53 of 54 checks passed
@westonruter westonruter deleted the add/fetchpriority-low-img-in-collapsed-accordion-item branch March 10, 2026 17:02
@github-project-automation github-project-automation bot moved this from 🔎 Needs Review to ✅ Done in WordPress 7.0 Editor Tasks Mar 10, 2026
@github-actions github-actions bot removed the Backport to WP 7.0 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Mar 10, 2026
gutenbergplugin pushed a commit that referenced this pull request Mar 10, 2026
…cks (#76336)

* Add fetchpriority=low to IMG tags in collapsed Accordion Item blocks

* Remove removal of loading attribute since handled by WordPress/wordpress-develop#11196

Co-authored-by: westonruter <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: im3dabasia <[email protected]>
@github-actions github-actions bot added the Backported to WP Core Pull request that has been successfully merged into WP Core label Mar 10, 2026
@github-actions
Copy link
Copy Markdown

I just cherry-picked this PR to the wp/7.0 branch to get it included in the next release: 947d78a

markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Mar 12, 2026
This updates the pinned hash from the `gutenberg` from `9b8144036fa5faf75de43d4502ff9809fcf689ad` to `8c78d87453509661a9f28f978ba2c242d515563b`.

The following changes are included:

- Navigation Editor: Allow any blocks to be inserted by gating contentOnly insertion rules to section blocks (WordPress/gutenberg#76189)
- Add `fetchpriority=low` to `IMG` tags in collapsed Details blocks (WordPress/gutenberg#76269)
- Connectors: Add logo URL support for custom AI providers (WordPress/gutenberg#76190)
- Cover Block: Add a playlist parameter to loop YouTube background videos. (WordPress/gutenberg#76004)
- Connectors: Memoize getConnectors selector (WordPress/gutenberg#76339)
- HTML Block: Fix broken layout (WordPress/gutenberg#76278)
- Tests: Skip connector logo URL tests when AI Client is unavailable (WordPress/gutenberg#76343)
- Navigation Overlay: Explicitly set fetchpriority for images (WordPress/gutenberg#76208)
- Connectors: Show API key source for env vars and wp-config constants (WordPress/gutenberg#76355)
- Connectors: Move API key validation and masking to REST dispatch level (WordPress/gutenberg#76327)
- Connectors: Replace apiFetch with core-data store selectors (WordPress/gutenberg#76333)
- Do not sync local attributes (WordPress/gutenberg#76267)
- Add `fetchpriority=low` to `IMG` tags in collapsed Accordion Item blocks (WordPress/gutenberg#76336)
- Implement disconnection debounce after initial connection (WordPress/gutenberg#76114)
- Allow Post Content to be edited when 'Show template' is active and Post content is nested in a Template Part (WordPress/gutenberg#76305)
- Fix: Document Bar: Back button flickers (WordPress/gutenberg#76320)
- RTC: Move event hooks from editor to core-data (WordPress/gutenberg#76358)
- fix(navigation): prevent right-justified submenu overflow in custom overlays (WordPress/gutenberg#76360)
- Connectors: Add connectors registry for extensibility (WordPress/gutenberg#76364)
- Connectors: Add empty state when no connectors are registered (WordPress/gutenberg#76375)
- Temp: Disable RTC in the site editor (WordPress/gutenberg#76223)
- Connectors: Add AI Experiments plugin callout with install/activate functionality (WordPress/gutenberg#76379)
- Editor: Polish real-time collaboration presence UI and move Avatar to editor package (WordPress/gutenberg#75652) (WordPress/gutenberg#76365)
- RTC: Add collaborator selection highlighting in rich text (WordPress/gutenberg#76107)
- Sync changes from `wp_enqueue_global_styles()` to Gutenberg override (WordPress/gutenberg#76127)
- [RTC] Fix performance regression on post save (WordPress/gutenberg#76370)
- Media: Enable AVIF support for client-side uploads (WordPress/gutenberg#76371)
- Connectors: Move plugin status computation to script module data (WordPress/gutenberg#76409)
- Revisions: Skip rendered fields in REST API responses (WordPress/gutenberg#76347)
- E2E Tests: Add connector setup flow tests with test AI provider (WordPress/gutenberg#76433)
- RTC: Place sync connection modal in front of popover (WordPress/gutenberg#76431)
- Connectors: Sync PHP code with WordPress Core (WordPress/gutenberg#76443)
- Editor: Show own presence in collaborative editing sessions (WordPress/gutenberg#76413) (WordPress/gutenberg#76445)

A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/9b8144036fa5faf75de43d4502ff9809fcf689ad…8c78d87453509661a9f28f978ba2c242d515563b.

Log created with:

git log --reverse --format="- %s" 9b8144036fa5faf75de43d4502ff9809fcf689ad..8c78d87453509661a9f28f978ba2c242d515563b | sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' | pbcopy

See #64595.

Built from https://develop.svn.wordpress.org/trunk@61988


git-svn-id: http://core.svn.wordpress.org/trunk@61270 1a063a9b-81f0-0310-95a4-ce76da25c4cd
dd32 pushed a commit to dd32/wordpress-develop that referenced this pull request Mar 12, 2026
This updates the pinned hash from the `gutenberg` from `9b8144036fa5faf75de43d4502ff9809fcf689ad` to `8c78d87453509661a9f28f978ba2c242d515563b`.

The following changes are included:

- Navigation Editor: Allow any blocks to be inserted by gating contentOnly insertion rules to section blocks (WordPress/gutenberg#76189)
- Add `fetchpriority=low` to `IMG` tags in collapsed Details blocks (WordPress/gutenberg#76269)
- Connectors: Add logo URL support for custom AI providers (WordPress/gutenberg#76190)
- Cover Block: Add a playlist parameter to loop YouTube background videos. (WordPress/gutenberg#76004)
- Connectors: Memoize getConnectors selector (WordPress/gutenberg#76339)
- HTML Block: Fix broken layout (WordPress/gutenberg#76278)
- Tests: Skip connector logo URL tests when AI Client is unavailable (WordPress/gutenberg#76343)
- Navigation Overlay: Explicitly set fetchpriority for images (WordPress/gutenberg#76208)
- Connectors: Show API key source for env vars and wp-config constants (WordPress/gutenberg#76355)
- Connectors: Move API key validation and masking to REST dispatch level (WordPress/gutenberg#76327)
- Connectors: Replace apiFetch with core-data store selectors (WordPress/gutenberg#76333)
- Do not sync local attributes (WordPress/gutenberg#76267)
- Add `fetchpriority=low` to `IMG` tags in collapsed Accordion Item blocks (WordPress/gutenberg#76336)
- Implement disconnection debounce after initial connection (WordPress/gutenberg#76114)
- Allow Post Content to be edited when 'Show template' is active and Post content is nested in a Template Part (WordPress/gutenberg#76305)
- Fix: Document Bar: Back button flickers (WordPress/gutenberg#76320)
- RTC: Move event hooks from editor to core-data (WordPress/gutenberg#76358)
- fix(navigation): prevent right-justified submenu overflow in custom overlays (WordPress/gutenberg#76360)
- Connectors: Add connectors registry for extensibility (WordPress/gutenberg#76364)
- Connectors: Add empty state when no connectors are registered (WordPress/gutenberg#76375)
- Temp: Disable RTC in the site editor (WordPress/gutenberg#76223)
- Connectors: Add AI Experiments plugin callout with install/activate functionality (WordPress/gutenberg#76379)
- Editor: Polish real-time collaboration presence UI and move Avatar to editor package (WordPress/gutenberg#75652) (WordPress/gutenberg#76365)
- RTC: Add collaborator selection highlighting in rich text (WordPress/gutenberg#76107)
- Sync changes from `wp_enqueue_global_styles()` to Gutenberg override (WordPress/gutenberg#76127)
- [RTC] Fix performance regression on post save (WordPress/gutenberg#76370)
- Media: Enable AVIF support for client-side uploads (WordPress/gutenberg#76371)
- Connectors: Move plugin status computation to script module data (WordPress/gutenberg#76409)
- Revisions: Skip rendered fields in REST API responses (WordPress/gutenberg#76347)
- E2E Tests: Add connector setup flow tests with test AI provider (WordPress/gutenberg#76433)
- RTC: Place sync connection modal in front of popover (WordPress/gutenberg#76431)
- Connectors: Sync PHP code with WordPress Core (WordPress/gutenberg#76443)
- Editor: Show own presence in collaborative editing sessions (WordPress/gutenberg#76413) (WordPress/gutenberg#76445)

A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/9b8144036fa5faf75de43d4502ff9809fcf689ad…8c78d87453509661a9f28f978ba2c242d515563b.

Log created with:

git log --reverse --format="- %s" 9b8144036fa5faf75de43d4502ff9809fcf689ad..8c78d87453509661a9f28f978ba2c242d515563b | sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' | pbcopy

See #64595.


git-svn-id: https://develop.svn.wordpress.org/trunk@61988 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [Block] Accordion Affects the Accordion Block [Package] Block library /packages/block-library [Type] Performance Related to performance efforts

Projects

Development

Successfully merging this pull request may close these issues.

Image in collapsed Accordion block may erroneously get fetchpriority=high even though hidden

3 participants