Gathering detailed insights and metrics for fg-loadjs
Gathering detailed insights and metrics for fg-loadjs
Gathering detailed insights and metrics for fg-loadjs
Gathering detailed insights and metrics for fg-loadjs
npm install fg-loadjs
Typescript
Module System
Node Version
NPM Version
69
Supply Chain
96.1
Quality
81.7
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
870,731
Last Day
44
Last Week
1,134
Last Month
8,725
Last Year
112,357
892 Stars
46 Commits
100 Forks
48 Watching
3 Branches
18 Contributors
Latest Version
1.1.0
Package Id
fg-loadjs@1.1.0
Unpacked Size
5.95 kB
Size
2.91 kB
File Count
4
NPM Version
6.4.1
Node Version
8.12.0
Cumulative downloads
Total Downloads
Last day
-89.7%
44
Compared to previous day
Last week
-52.9%
1,134
Compared to previous week
Last month
-10.3%
8,725
Compared to previous month
Last year
-6.3%
112,357
Compared to previous year
No dependencies detected.
A simple function for asynchronously loading JavaScript files
Place the loadJS
function inline in the head
of your page (it can also be included in an external JavaScript file if preferable).
Then call it by passing it a JavaScript URL:
1<head> 2... 3<script> 4 // include loadJS here... 5 function loadJS( src ){ ... } 6 // load a file with loadJS 7 loadJS( "path/to/script.js" ); 8</script> 9... 10</head>
You can execute code after the Script has loaded via a callback:
1<head> 2... 3<script> 4 // include loadJS here... 5 function loadJS( src ){ ... } 6 // load a file with loadJS 7 loadJS( "path/to/script.js", function() { 8 // file has loaded 9 }); 10</script> 11... 12</head>
You can ensure ordered execution of multiple asynchronous by passing true
as the second or third parameter. Only supported in browsers that support the async
attribute (No IE8/IE9 support).:
1loadJS( "path/to/library.js", true ); 2loadJS( "path/to/plugins.js", true ); 3loadJS( "path/to/last.js", function() { 4 //all scripts loaded 5}, true );
<script src="..." async defer>
?The async
and defer
attributes enjoy broad browser support. They're great options when all you need to do is load a script for all users, ideally in a non-blocking manner. The limitations with these attributes are:
async
(though defer has broader support so it's typically not a problem)async
, but in order.Number 2 above is the main reason we use loadJS
. Say you want to check if querySelector
is supported before requesting your entire DOM framework and UI scripting - you'll need to use a script loader to do that. But again, if you just want to load a script unconditionally, these attributes are recommended.
async
script loading of crucial scripts is to inline loadJS
before any other stylesheets and scripts and use it either immediately or within a setTimeout
.1<script> 2 // include loadJS here... 3 function loadJS( src ){ ... } 4 5 setTimeout(function(){ 6 loadJS( "path/to/library.js", true ); 7 8 if ( !hasFeature ) { 9 loadJS( "path/to/polyfill.js", true ); 10 } 11 12 loadJS( "path/to/app.js", true ); 13 }); 14</script> 15 16... 17 18<link rel="stylesheet" href="path/to/styles.css" />
Both are very much appreciated - especially bug fixes. As for contributions, the goals of this project are to keep things very simple and utilitarian, so if we don't accept a feature addition, it's not necessarily because it's a bad idea. It just may not meet the goals of the project. Thanks!
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 5/25 approved changesets -- score normalized to 2
Reason
project is archived
Details
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
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-12-16
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