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 component that makes it easy to load 3rd party scripts
npm install react-load-script
Typescript
Module System
Node Version
NPM Version
90.1
Supply Chain
88.2
Quality
74.7
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
35,055,150
Last Day
9,237
Last Week
83,184
Last Month
456,137
Last Year
5,766,526
359 Stars
19 Commits
30 Forks
24 Watching
7 Branches
9 Contributors
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
Publised On
12 Jul 2017
Cumulative downloads
Total Downloads
Last day
-58%
9,237
Compared to previous day
Last week
-25.8%
83,184
Compared to previous week
Last month
-6.6%
456,137
Compared to previous month
Last year
5.1%
5,766,526
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
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
77 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-12-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