@topefekt/asset-loader
v1.0.4
Published
Performant Javascript files loading
Downloads
4
Readme
@topefekt/asset-loader
Delightful loading of javascript files in browser.
Features
- Resolves dependencies of scripts
- Pre-load scripts
- Lazy load scripts
- Inline script handling
- Hook API
Usage
Load asset-loader library
Latest version
<script type="text/javascript" src="https://unpkg.com/@topefekt/asset-loader/umd/loader.production.js"></script>
Stable version 1
<script type="text/javascript" src="https://unpkg.com/@topefekt/[email protected]/umd/loader.production.js"></script>
Load some assets
We can pass either array or object to load method. We strongly recommends pass objects because of merging nature and better referencing of dependencies
<script type="text/javascript">
assetLoader.load({
jquery: {filename: "https://unpkg.com/[email protected]/dist/jquery.js"},
myFile: {filename: "/path/to/file.js", dependencies: ["jquery"]},
myFile2: {filename: "/path/to/file2.js", dependencies: ["myFile", "myFile3"]},
myFile3: {filename: "/path/to/file3.js"},
});
//load scripts in this order:
//1. jquery|myFile3
//2. myFile
//3. myFile2
</script>