Skip to content

A vanilla web component for including external media

License

Notifications You must be signed in to change notification settings

vanillawc/wc-include

Repository files navigation

<wc-include> Include HTML from an External Source

GitHub Releases NPM Releases Bundlephobia Latest Status Release Status

Discord Published on WebComponents.org

Installation

Installation

npm i @vanillawc/wc-include

Import from NPM

<script type="module" src="node_modules/@vanillawc/wc-include/index.js"></script>

Import from CDN

<script type="module" src="https://cdn.jsdelivr.net/gh/vanillawc/wc-include@1/index.js"></script>

Demo

Try it on WebComponents.dev

Usage

Attributes

  • shadow - if present the contents are contained in a shadowDOM

Basic Usage

The src attribute imports the contents of the file into the lightDOM.

<wc-include src="./sample.html"></wc-include>

'shadow' Attribute Usage

When the shadow attribute is specified, the imported contents will be encapsulated in a shadowDOM.

<wc-include src="./sample.html" shadow></wc-include>

Contributing

See CONTRIBUTING.md