Function loadFragment

  • Fetches markup from a remote link and creates a document fragment out of it.

    Parameters

    • href: string

      The link to load the markup from

    • init: RequestInit

      The request init used with fetch

    Returns Promise<DocumentFragment>

    A promise that resolves to the document fragment.

    Example

    import { loadFragment } from 'inherent';
    const frag1 = await loadFragment(`./my/fragment.html`)
    // <p>Para 1</p><p>Para 2</p>