https://github.com/dsheiko/micro-requirejs
⛔️ [DEPRECATED] Tiny asynchronous dependency loader, that does not require modification of dependent scripts
https://github.com/dsheiko/micro-requirejs
depricated obsolete script-loader
Last synced: 10 months ago
JSON representation
⛔️ [DEPRECATED] Tiny asynchronous dependency loader, that does not require modification of dependent scripts
- Host: GitHub
- URL: https://github.com/dsheiko/micro-requirejs
- Owner: dsheiko
- Created: 2013-04-16T09:06:15.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T17:49:22.000Z (about 3 years ago)
- Last Synced: 2024-11-20T08:06:39.897Z (about 1 year ago)
- Topics: depricated, obsolete, script-loader
- Language: JavaScript
- Homepage:
- Size: 367 KB
- Stars: 22
- Watchers: 3
- Forks: 6
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Micro RequireJS v2.0
==============
[](http://unmaintained.tech/)
> WARNING - THIS PROJECT IS NO LONGER MAINTAINED!!!
[](https://nodei.co/npm/micro-requirejs/)
[](https://travis-ci.org/dsheiko/micro-requirejs)
[](http://badge.fury.io/bo/micro-requirejs)
Extremely simple and light-weight (**<1KB** gzipped) asynchronous resource (JavaScript and CSS) loader
If you need support of legacy (like ancient) browsers, go with micro-requirejs v1.x
## How to use
```html
...
rjs([
"https://code.jquery.com/jquery-3.3.1.slim.min.js",
"https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
])
.then(() => {
console.log( "jQuery available, Bootstrap CSS available." );
return rjs("https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js")
.then(() => {
console.log( "Bootstrap JS available." );
});
})
.catch(( err ) => {
console.error( "Something went wrong", err );
});
```
### Async function style
```js
async function main() {
try {
await rjs([
"https://code.jquery.com/jquery-3.3.1.slim.min.js",
"https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
]);
await rjs( "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" );
console.log( "jQuery and Bootstrap loaded" );
} catch ( err ) {
console.error( err );
}
}
main();
```
### Injecting extra attributes
```js
// Single source
await rjs( "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js", {
integrity: "sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy",
crossorigin: "anonymous"
});
// Multiple sources
await rjs([
["https://code.jquery.com/jquery-3.3.1.slim.min.js", {
integrity: "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo",
crossorigin: "anonymous"
}],
"https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
]);
```
You can run tests like that:
```
npm test
```
[](http://githalytics.com/dsheiko/micro-requirejs)