Registry / testing / fetch-js

fetch-js

JSON →
library1.0.3jsnpmunverified

A lightweight, reliable script loader for browsers that fetches JavaScript files and executes callbacks once the script is evaluated. Version 1.0.3 is the current stable release with no active development. It works with CommonJS (require) and has no dependencies. Key differentiator: it focuses solely on script loading with error handling, unlike heavier loaders like RequireJS or SystemJS.

npm install fetch-js
INSTALL
IMPORT
SIG · FETCH-JS
F
fetch-js
testingjavascriptv1.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fetchJs
✓ const fetchJs = require('fetch-js')
✗ import fetchJs from 'fetch-js'
Package is CommonJS only; no ESM support available.

Show how to install and use fetch-js to load a jQuery script with error handling.

const fetchJs = require('fetch-js'); fetchJs('https://code.jquery.com/jquery-3.6.0.min.js', function(err) { if (err) { console.error('Failed to load script:', err); return; } console.log('Script loaded and executed!'); // jQuery is now available });
Debug
Known issues
deprecatedPackage is no longer actively maintained; consider using native <script> loading or modern alternatives.
fix
Use dynamic import() or a more modern script loader like scriptjs or loadjs.
affects: >=1.0.0
gotchaNo ESM support; cannot use import syntax.
fix
Use require() or switch to an ESM-compatible package.
affects: >=1.0.0
gotchaDoes not support parallel loading of multiple scripts without chaining callbacks.
fix
Chain fetchJs calls manually or use a Promise-based wrapper.
affects: >=1.0.0
Errors
Common errors & fixes
Uncaught TypeError: fetchJs is not a function
Using ES6 import syntax instead of CommonJS require.
fix
Use `const fetchJs = require('fetch-js');`
Error: Script load error: ...
Network issues or incorrect URL; script fails to load.
fix
Ensure the URL is correct and the CDN/script is reachable.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
fetch-js — npm install fetch-js · libregistry