Skip to content

Avoid preloading empty href attributes with Optimize critical images #7116

@camilamadronero

Description

@camilamadronero

Describe the bug
The Optimize critical images feature adds a preload tag for empty href values.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://neo.law/ or any site with a markup such as <div style="background-image:url();"></div> as a markup for LCP element.
  2. Run Optimize critical images on it.
  3. See the resulting preload markup: <link rel="preload" data-rocket-preload as="image" href="" fetchpriority="high">

Expected behavior
Optimize critical images should avoid adding a preload tag in these conditions.

Screenshots
Original markup: https://jmp.sh/34iunv8H
Preload tag: https://jmp.sh/y6BkzWZq

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Ticket: https://secure.helpscout.net/conversation/2762969880/523284?viewId=273761
Slack thread: https://wp-media.slack.com/archives/C072P5EU5DF/p1731706632758679

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: OCIOptimize Critical Imagestype: enhancementImprovements that slightly enhance existing functionality and are fast to implement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions