load-resource-from-url
v1.0.0
Published
> Dynamically load JavaScript resource directly from a URL.
Readme
load-resource-from-url
Dynamically load JavaScript resource directly from a URL.
load-resource-from-url is a tiny Node.js module that fetches a JavaScript resource from a URL and returns it as a callable resource. Perfect for dynamically loading resource at runtime.
🚀 Installation
npm install load-resource-from-url⚡ Usage
import { LoadResourceFromUrl } from 'load-resource-from-url';
async function main() {
// URL containing the JavaScript resource
const url = 'https://example.com/my-resource.js';
const loadResource = await LoadResourceFromUrl(url);
// Load the fetched resource
loadResource();
}
main();✅ Example
Suppose the content at https://example.com/hello.js is:
console.log('Hello from a remote resource!');Then:
import { LoadResourceFromUrl } from 'load-resource-from-url';
const loadResource = await LoadResourceFromUrl('https://example.com/hello.js');
loadResource(); // Prints: Hello from a remote resource!