async-components
v2.1.1
Published
Async Components
Downloads
10
Maintainers
Readme
async-components
Async components allows splitting the web into independent components and easily integrate them, asynchronously.
Demo
http://msn0.github.io/async-components
Installation
npm i async-components
# or
bower i async-components
Usage
Include async-components straight after the <body>
tag:
<script src="async-components.es5.min.js"></script>
Define components:
<body>
<div data-component="/header.html" data-event="header-loaded"></div>
<div data-component="/listing.html" data-event="listing-loaded"></div>
<div data-component="/footer.html" data-event="footer-loaded"></div>
</body>
Once component is loaded, the corresponding event is emmited. Let's say listing
depends on header
. Then listing
should listen for header-loaded
event, e.g.
document.addEventListener('header-loaded', (data) => {
console.log(data);
});
License
MIT