Skip to content

Installation

ResourceLoader.js is a single JavaScript file with no dependencies. You can add it to any project in minutes.

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>
CDNURLNotes
jsDelivr (latest)https://cdn.jsdelivr.net/npm/resourceloader-js/resourceLoader.jsAlways the newest release
jsDelivr (pinned)https://cdn.jsdelivr.net/npm/resourceloader-js@1.0.2/resourceLoader.jsLocked to a specific version
unpkg (latest)https://unpkg.com/resourceloader-js/resourceLoader.jsAlways the newest release
unpkg (pinned)https://unpkg.com/resourceloader-js@1.0.2/resourceLoader.jsLocked to a specific version

Install the package from the npm registry:

Terminal window
npm install resourceloader-js

Once 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 available
ResourceLoader.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');

  1. Download resourceLoader.js from the GitHub repository.
  2. Place it in your project, for example at ./js/resourceLoader.js.
  3. Reference it with a <script> tag:
<script src="./js/resourceLoader.js"></script>

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.


Now that ResourceLoader.js is installed, head to the Quick Start guide to load your first resources in a few lines of code.