Installation
ResourceLoader.js is a single JavaScript file with no dependencies. You can add it to any project in minutes.
Option 1: CDN (Recommended for Beginners)
Section titled “Option 1: CDN (Recommended for Beginners)”The easiest way to get started is to include the library directly from a CDN. Paste this <script> tag into your HTML file, inside the <head> section:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>My Page</title>
<!-- Add ResourceLoader.js here --> <script src="https://cdn.jsdelivr.net/npm/resourceloader-js/resourceLoader.js"></script></head><body> <script> // ResourceLoader is now available globally ResourceLoader.include(['https://example.com/app.css']); </script></body></html>Latest vs. Pinned Versions
Section titled “Latest vs. Pinned Versions”| CDN | URL | Notes |
|---|---|---|
| jsDelivr (latest) | https://cdn.jsdelivr.net/npm/resourceloader-js/resourceLoader.js | Always the newest release |
| jsDelivr (pinned) | https://cdn.jsdelivr.net/npm/resourceloader-js@1.0.2/resourceLoader.js | Locked to a specific version |
| unpkg (latest) | https://unpkg.com/resourceloader-js/resourceLoader.js | Always the newest release |
| unpkg (pinned) | https://unpkg.com/resourceloader-js@1.0.2/resourceLoader.js | Locked to a specific version |
Option 2: npm
Section titled “Option 2: npm”Install the package from the npm registry:
npm install resourceloader-jsOnce installed, you can include it in your project in two ways.
Browser global (via a bundler or <script src>)
Section titled “Browser global (via a bundler or <script src>)”If you are using a bundler (Webpack, Vite, Rollup, Parcel), you can import it in your entry file:
import 'resourceloader-js';
// The global ResourceLoader is now availableResourceLoader.include(['https://example.com/app.css']);Or if your bundler exposes modules as named exports, you may use:
import ResourceLoader from 'resourceloader-js';CommonJS (Node.js / server-side rendering)
Section titled “CommonJS (Node.js / server-side rendering)”const ResourceLoader = require('resourceloader-js');Option 3: Direct Download
Section titled “Option 3: Direct Download”- Download
resourceLoader.jsfrom the GitHub repository. - Place it in your project, for example at
./js/resourceLoader.js. - Reference it with a
<script>tag:
<script src="./js/resourceLoader.js"></script>Verify the Installation
Section titled “Verify the Installation”After including the library, open your browser’s developer console and run:
console.log(typeof ResourceLoader); // "object"console.log(typeof ResourceLoader.include); // "function"If you see "object" and "function", the library is loaded and ready to use.
Next Steps
Section titled “Next Steps”Now that ResourceLoader.js is installed, head to the Quick Start guide to load your first resources in a few lines of code.