New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

use-script-loader

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-script-loader

React.js script loader hook

Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
1.1K
-12.61%
Maintainers
1
Weekly downloads
 
Created
Source

use-script-loader hook

Inspired by scriptLoader2

install

npm install use-script-loader --save

usage

const useScriptLoader = require('use-script-loader')

const { isLoading } = useScriptLoader('foo.js')
console.log(script.src);    // Prints 'foo'.js' after loading
if (!isLoading) {
  // use foo.js
}

API

object = useScriptLoader(src, [attrs], [parentNode], [skip])

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.

skip (optional)

If true, will not append script. Default value is false

object: { isLoading }

Returns an object which contains isLoading flag that will remain true till the script is loaded

license

MIT. Copyright (c) Eesa Abid.

Keywords

reactjs

FAQs

Package last updated on 17 Sep 2020

Did you know?

Socket

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.

Install

Related posts