loadx
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

loadx npm CI

Simple asset loader that allows loading of image, CSS, and JavaScript files, using the Promise API, and fires a callback upon success or failure.

  • 🚚 Load JS, CSS or Image
  • 🚀 Cache results
  • ⏳️ Works beautifully with promise and async/await
  • 📦️ Just 400 bytes of gzipped ES3

Install

$ npm install --save loadx

Usage

import loadx from 'loadx';

async function loadResources() {
	// loading a JavaScript resource
	await loadx.js('https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.min.js');

	// from here, you can start using axios regularly
	const user = await axios.get('/user?ID=12345');

	// you can load CSS...
	await loadx.css('https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css');

	// ...and image as well
	const imageElement = await loadx.img('https://picsum.photos/200/300');
}

License

Apache-2.0 © Cesar William

Package Sidebar

Install

npm i loadx

Weekly Downloads

25

Version

0.2.0

License

Apache-2.0

Unpacked Size

41.6 kB

Total Files

14

Last publish

Collaborators

  • cesarwbr