adapter-static: Placing media before srcset in a <source> tag will prevent srcset from being crawled
See original GitHub issueDescribe 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:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
fixed by https://github.com/sveltejs/kit/pull/3288