includeHTML - Loading HTML parts via HTML tag (pure js)
Supported protocols: http://, https://, file:///
Supported browsers: IE 9+, FF, Chrome (and may be other)
npm i -S includehtml.js
- npm package
1.Insert includeHTML into head section in HTML file:
<script src="js/includeHTML.js"></script>
2.Anywhere use includeHTML as HTML tag:
<div><include src="header.html"></include></div>
1.Tag:
<include scr="menu.html"></include>
2.Async:
<script>
includeHTML('header.html', document.getElementById('mainmenu'));
includeHTML('menu.html', document.getElementById('pagemenu'));
</script>
3.Sync:
<script>
includeHTML([
['header.html', document.getElementById('headder')],
['menu.html', document.getElementById('menu')],
['footer.html', document.getElementById('footer')]
], function(){
//optional callback
});
</script>
- To build script run
npm run build