# a-include

> Custom Element for Client-Side Include of a link

Latest version **1.0.2** (published 2021-02-26) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install a-include
pnpm add a-include
yarn add a-include
bun add a-include
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-02-26 |
| First published | 2021-02-22 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jochen Christ |
| Maintainers | jochenchrist |
| Keywords | a-include, include, client side include |

## Links

- npm: https://www.npmjs.com/package/a-include
- Homepage: https://github.com/selfcontainedsystems/a-include
- npm.io page: https://npm.io/package/a-include

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2021-02-26
- 1.0.1 — 2021-02-22
- 1.0.0 — 2021-02-22

## README

# a-include

Custom element to include HTML content via plain JavaScript.

## Demo

https://unpkg.com/a-include/example/demo.html

## Usage

### Include Fragments

The `a-include` tag gets replaced with the content of [fragment.html](example/fragment.html).

```html
<a-include>
  <a href="./fragment.html">Link</a>
</a-include>

<!-- defines custom element a-include -->
<script type="module" src="https://unpkg.com/a-include@1.0.1/a-include.js"></script>
```

The `a-include` tag is built with progressive enhancement in mind.
The content is included asynchronously.
If - for whatever reason - the content can not be loaded, the `<a href="...">` Link is still available
as a fallback or for accessibility concerns.

To remove the link from being rendered use an empty `a` tag:

```html
<a-include>
  <a href="./fragment.html"></a>
</a-include>
```

### Include Fragments from Full Pages

Sometimes only a specific part of the HTML page should be included.
Specify a query selector for the content to include with the `selector` attribute.
In this example, we only include the `main` html element from the [fullpage.html](example/fullpage.html). 

```html
<a-include selector="main">
  <a href="./fullpage.html">Link</a>
</a-include>

<!-- defines custom element a-include -->
<script src="./a-include.js"></script>
```

---
_Source: https://npm.io/package/a-include · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
