Gathering detailed insights and metrics for react-load-script
Gathering detailed insights and metrics for react-load-script
Gathering detailed insights and metrics for react-load-script
Gathering detailed insights and metrics for react-load-script
react-script-hook
React hook to dynamically load an external script and know when its loaded
react-async-load-script
Async script loader HOC for React
react-stripe-script-loader
React component that lets load Stripe script and shows React Stripe Elements
react-async-script-loader
A decorator for script lazy loading on react component
React component that makes it easy to load 3rd party scripts
npm install react-load-script
Typescript
Module System
Node Version
NPM Version
96.1
Supply Chain
88.2
Quality
74.7
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
37,518,636
Last Day
2,537
Last Week
99,815
Last Month
436,516
Last Year
5,743,820
MIT License
359 Stars
19 Commits
30 Forks
23 Watchers
7 Branches
9 Contributors
Updated on Oct 16, 2024
Minified
Minified + Gzipped
Latest Version
0.0.6
Package Id
react-load-script@0.0.6
Size
40.51 kB
NPM Version
5.0.3
Node Version
8.1.3
Published on
Jul 12, 2017
Cumulative downloads
Total Downloads
Last Day
-13.9%
2,537
Compared to previous day
Last Week
-9%
99,815
Compared to previous week
Last Month
-11.2%
436,516
Compared to previous month
Last Year
4.9%
5,743,820
Compared to previous year
2
20
This package simplifies loading of 3rd party scripts in your React applications.
There are situations when you need to use a 3rd party JS library in your React application (jQuery, D3.js for rendering charts, etc.) but you don't need it everywhere and/or you want to use it only in a response to users actions. In cases like this, preloading the whole library when application starts is an unnecessary and expensive operation which could possibly slow down your application.
Using the Script
component this package provides you with, you can easily load any 3rd party scripts your applications needs directly in a relevant component and show a placeholder while the script is loading (e.g. a loading animation). As soon as the script is fully loaded, a callback function you'll have passed to Script
is called (see example below).
This package requires React 0.14.9 and higher.
The package exports a single component with the following props:
onCreate
Called as soon as the script tag is created.
onError
(required)Called in case of an error with the script.
onLoad
(required)Called when the requested script is fully loaded.
url
(required)URL pointing to the script you want to load.
attributes
An object used to define custom attributes to be set on the script element. For example, attributes={{ id: 'someId', 'data-custom: 'value' }}
will result in <script id="someId" data-custom="value" />
You can use the following code to load jQuery in your app:
1import Script from 'react-load-script' 2 3... 4 5render() { 6 return ( 7 <Script 8 url="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" 9 onCreate={this.handleScriptCreate.bind(this)} 10 onError={this.handleScriptError.bind(this)} 11 onLoad={this.handleScriptLoad.bind(this)} 12 /> 13 ) 14} 15 16... 17 18handleScriptCreate() { 19 this.setState({ scriptLoaded: false }) 20} 21 22handleScriptError() { 23 this.setState({ scriptError: true }) 24} 25 26handleScriptLoad() { 27 this.setState({ scriptLoaded: true }) 28} 29
MIT 2016
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/14 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
79 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More