question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

adapter-static: Placing media before srcset in a <source> tag will prevent srcset from being crawled

See original GitHub issue

Describe the bug

If the attributes in a <source> tag appear like so <source media="(max-width: 400px)" srcset="/myimage.jpg"> the srcset won’t be crawled and the image won’t be downloaded.

When arranged like this <source srcset="/myimage.jpg" media="(max-width: 400px)"> it works as expected.

Reproduction

Add a <source> tag as mentioned above and run a SvelteKit build with adapter-static configured. Images will not be downloaded as expected.

Logs

No response

System Info

System:
    OS: Linux 5.10 Alpine Linux
    CPU: (6) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 4.01 GB / 7.77 GB
    Container: Yes
    Shell: 1.31.1 - /bin/ash
  Binaries:
    Node: 14.18.1 - /usr/local/bin/node
    Yarn: 1.22.15 - /usr/local/bin/yarn
    npm: 6.14.15 - /usr/local/bin/npm
  npmPackages:
    @sveltejs/adapter-static: ^1.0.0-next.21 => 1.0.0-next.21
    @sveltejs/kit: next => 1.0.0-next.183
    svelte: ^3.43.1 => 3.43.2

Severity

serious, but I can work around it

Additional Information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
Conduitrycommented, Nov 7, 2021

I’ve wondered whether it would be a good idea to give up on regexes here and just use something like parse5 to parse the HTML and walk the AST ourselves to find stuff more robustly. If this only ever happens at build time, I guess I see less of a cost to doing this with a bigger slower library.

2reactions
Rich-Harriscommented, Jan 11, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

What Img Srcset Does In HTML5: A Quick & Simple Guide »
Defines multiple sizes of the same image, allowing the browser to select the appropriate image source. Contents [hide]. 1 The Problem: Different Resolutions...
Read more >
Responsive images - Learn web development | MDN
In this article, we'll learn about the concept of responsive images — images that work well on devices with widely differing screen sizes, ......
Read more >
Responsive Images: If you're just changing resolutions, use ...
Think of srcset as suggestions or just extra information to help a browser decide. Ultimately it can do what it thinks is right....
Read more >
Does Google index images declared using 'srcset'?
I've submitted the page to be indexed and will add the result here. ... (which are the ones I specified in src attribute...
Read more >
How to Use HTML5 “picture”, “srcset”, and “sizes” for ...
Instead of loading a single image and trying to resize it to suit all possible viewport sizes and layouts, the picture tag loads...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found