Skip to content

Conversation

caub
Copy link

@caub caub commented Apr 2, 2021

No description provided.

module.exports = function loadScript2 (src, attrs, parentNode) {
const node = parentNode || document.head || document.getElementsByTagName('head')[0]
const existingScript = node.querySelector(`:scope > script[src="${src}"]`)
if (existingScript) return existingScript
Copy link
Author

@caub caub Apr 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@feross this allows to cache the added script

it can be useful when you render more than once a component that uses loadScript, for example a modal component

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant