Comment

Comment by mewpmewp2

Technically you could also just write a bit of JS within the HTML to do without needing any of the first 3.

You could querySelectorAll and check the src attribute etc, then fetch the content put it in the innerHTML.

    <remote-fragment src="https://..." />

    <script>

      document.querySelectorAll("remote-fragment").forEach(async (el) => {

        const src = el.getAttribute("src");

        const result = await fetch(src).then((res) => res.text());

        el.innerHTML = result;

      });

    </script>

Or if you want to react to any such component inserted at times down the line or src attribute changes, you could use MutationObserver.
parent mewpmewp2 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton