Skip to content

srcset hydration results in expensive DOM updates #8838

@benmccann

Description

@benmccann

Describe the bug

Svelte always thinks the client side srcset is different from the server side srcset. For sites that make heavy use of picture (e.g. via a generic Image component like in sveltejs/kit#241 (comment) or sveltejs/kit#9787) this ends up being really expensive.

If /myimg.png is SSR'd, the client-side URL contains the full URL including hostname, so Svelte thinks they don't match. There's special logic for this around an img src attribute, but srcset was overlooked.

b`if (!@src_url_equal(${element.var}.src, ${init})) ${method}(${element.var}, "${name}", ${this.last});`

Reproduction

Any picture with a srcset

Logs

No response

System Info

Happens with 3.x and 4.0

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    compilerChanges relating to the compilerperf

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions