-
-
Save Comandeer/d21b12311837b0fa4d0f47f392ff4b93 to your computer and use it in GitHub Desktop.
Fetching only needed elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return fetch( URL ).then( ( response ) => { | |
return response.text(); | |
} ).then( ( html ) => { | |
const parser = new DOMParser(); | |
const document = parser.parseFromString( html, 'text/html' ); | |
const head = document.head; | |
const template = head.querySelector( 'template' ); | |
const style = head.querySelector( 'style' ); | |
const script = head.querySelector( 'script' ); | |
return { | |
template, | |
style, | |
script | |
}; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment