img-switch

The element device width (element.width * devicePixelRatio) based <img> chooser.

<link rel="stylesheet" href="styles.css">
<script src="switch-img/index.js"></script>

<img-switch>
  <source data-device-width="400" src="image-400x400.webp">
  <source data-device-width="800" src="image-800x800.webp">
  <source src="image-1600x1600.webp">
</img-switch>