
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
load-script2
Advanced tools
Works in the browser with browserify!
npm install load-script2
const loadScript = require('load-script2')
const script = await loadScript('foo.js')
console.log(script.src);// Prints 'foo'.js'
load-script
load-script2
does not support legacy browsers like IE8 because these browsers
do not have standards-based DOM APIs. load-script2
also removes many esoteric
options, which aren't needed most of the time and adds promises support.
The sise of load-script2
is 492 bytes, compared to 655 bytes for load-script
(minified
and gzipped).
promise = loadScript(src, [attrs], [parentNode])
Append a <script>
node with the given src
URL to the <head>
element in the DOM.
src
Any url that you would like to load. May be absolute or relative.
attrs
(optional)An object that contains HTML attributes to set on the <script>
tag. For
example, the value { id: 'hi' }
would set the attribute id="hi"
on the
<script>
tag before it is injected.
parentNode
(optional)The HTML node to which the <script>
tag will be appended. If not specified,
defaults to the <head>
tag.
promise
Returns a promise which resolves to the script
node that was appended to the
DOM, or rejects with err
if any occurred.
MIT. Copyright (c) Feross Aboukhadijeh.
FAQs
Dynamic script loading for modern browsers
The npm package load-script2 receives a total of 11,102 weekly downloads. As such, load-script2 popularity was classified as popular.
We found that load-script2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.