Web component / esm

<img-enlarge>

Load the component from esm.sh. See the README for installation and API details.

Import and register the class

This import gives you the class without registering it. Use customElements.define() to make img-enlarge available on the page. If the CDN can’t load, the image remains visible.

<script type="module">
  import { ImgEnlargeElement } from
    'https://esm.sh/@aarongustafson/img-enlarge@1.2.0/img-enlarge.js?bundle&target=es2022';

  if (!customElements.get('img-enlarge')) {
    customElements.define('img-enlarge', ImgEnlargeElement);
  }
</script>

<img-enlarge>
  <img src="./bicycle.svg" alt="A red bicycle with a basket.">
</img-enlarge>
A red bicycle with a basket.