Prevent image source from loading automatically

I got the following code:

<picture>
  <source media="(min-width: 960px)" srcset="http://placehold.it/960x150">
  <source media="(min-width: 575px)" srcset="http://placehold.it/575x150">
  <img src="" alt="">
</picture>

When the page loads, img src is automatically replaced with the first matched source element. Is there a way to prevent this automatic replacement when the page first loads? I thought of something like an additional html attribute.

+4
source share
1 answer

Which browser are you testing?

<picture>
  <source media="(min-width: 960px)" srcset="http://placehold.it/960x150">
  <source media="(min-width: 575px)" srcset="http://placehold.it/575x150">
  <img src="" alt="">
</picture>

This seems to work fine in Chrome . The image function has not received full support , so this may be a problem.

0
source

Source: https://habr.com/ru/post/1610939/


All Articles