Fork me on GitHub

h-include.js

Declarative client-side transclusion, using Custom Elements V1. Perfect for Microfrontend architectures, in combination with server-side transclusion technologies like Edge-Side Includes.

Based on hinclude.js by @mnot.

Basic usage

h-include adds <h-include> as a Custom Element. When the browser encounters this element, it will fetch and include the HTML resource linked in the src attribute.

Wherever you want to include something, do this:

  <h-include src="demo/basic/fragment.html"></h-include>

Advanced usage

Fragment extraction

Extract a fragment from a full HTML resource:

Media query support

Extensions

h-import

If possible, use Edge-Side Includes to import statically loaded resource fragments, due to performance reasons.

h-include-lazy

Go to bottom of page

h-import-lazy

Go to bottom of page

h-include-navigate

Example:






































Back to top