Comment Comment by typedef_struct You could start with something like this: customElements.define('html-import', class extends HTMLElement { connectedCallback() { const href = this.getAttribute('href') const fetch = new XMLHttpRequest() fetch.responseType = 'document' fetch.addEventListener('readystatechange', (function onfetch(e) { if (fetch.readyState !== XMLHttpRequest.DONE) return const document = fetch.response.querySelector('body') ?? fetch.response this.replaceWith(document) }).bind(this)) fetch.open('GET', href) fetch.send() } }) parent typedef_struct 1 year ago