# element-loaded-by-id

> Promise for when an element matching an ID is loaded into the DOM.

Latest version **0.0.3** (published 2023-05-29) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install element-loaded-by-id
pnpm add element-loaded-by-id
yarn add element-loaded-by-id
bun add element-loaded-by-id
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2023-05-29 |
| First published | 2023-05-29 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Damien Bezborodov |
| Maintainers | dbezborodov |
| Keywords | promise, mutationobserver |

## Links

- npm: https://www.npmjs.com/package/element-loaded-by-id
- Repository: https://github.com/bezborodow/element-loaded-by-id
- Homepage: https://github.com/bezborodow/element-loaded-by-id#readme
- Issues: https://github.com/bezborodow/element-loaded-by-id/issues
- npm.io page: https://npm.io/package/element-loaded-by-id

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 0.0.3 (latest) — 2023-05-29
- 0.0.2 — 2023-05-29
- 0.0.1 — 2023-05-29

## README

# `elementLoadedById()`

Detect when an [element](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement)
matching an [ID](https://developer.mozilla.org/en-US/docs/Web/API/Element/id)
is loaded into the [DOM](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model).

## Synopsis

```javascript
elementLoadedById(id)
    .then((element) => {
        // ...
    });
```

## Syntax
```
elementLoadedById(id)
```

### Parameters

**`id`**: A unique ID for the element.

### Return Value

A [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that is:

 * **Already fulfilled**, if the element is found already loaded into the
   [document](https://developer.mozilla.org/en-US/docs/Web/API/Window/document).
 * **Already rejected**, if the element was not found and the DOM has already
   [finished
   loading](https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState).
 * **Asynchronously fulfilled**, when a
   [mutation](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver)
   occurs that adds the element into the DOM.
 * **Asynchronously rejected**, when the DOM has [finished
   loading](https://developer.mozilla.org/en-US/docs/Web/API/Window/DOMContentLoaded_event)
   and the element has not been found.

## Description

`elementLoadedById()` will search the document for the element by ID.
It will continue searching until the DOM has finished loading ([`DOMContentLoaded`
event](https://developer.mozilla.org/en-US/docs/Web/API/Window/DOMContentLoaded_event)).

See also:

  * [`elementLoaded()`](https://github.com/bezborodow/element-loaded)

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