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>