# stylesheet-inject

> Dynamically load CSS snippets and stylesheets at browser runtime

Latest version **1.2.2** (published 2016-09-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install stylesheet-inject
pnpm add stylesheet-inject
yarn add stylesheet-inject
bun add stylesheet-inject
```

## 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.2.2 |
| Published | 2016-09-13 |
| First published | 2016-09-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | jdcrensh@gmail.com |
| Maintainers | jdcrensh |
| Keywords | javscript, js, css, style, stylesheet, inject, load, loading, loader, dynamic, browser |

## Links

- npm: https://www.npmjs.com/package/stylesheet-inject
- Repository: https://github.com/jdcrensh/stylesheet-inject
- Homepage: https://github.com/jdcrensh/stylesheet-inject#readme
- Issues: https://github.com/jdcrensh/stylesheet-inject/issues
- npm.io page: https://npm.io/package/stylesheet-inject

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.2.2 (latest) — 2016-09-13
- 1.2.1 — 2016-09-13
- 1.2.0 — 2016-09-13
- 1.1.0 — 2016-09-13
- 1.0.1 — 2016-09-04
- 1.0.0 — 2016-09-04
- 0.0.1 — 2016-09-04

## README

# stylesheet-inject

[![npm](https://img.shields.io/npm/v/stylesheet-inject.svg?maxAge=2592000)](https://www.npmjs.com/package/stylesheet-inject)

Dynamically load CSS snippets and stylesheets at browser runtime. **Standalone utility (no dependencies)**

## Install

`npm install -S stylesheet-inject` or use the CDN version.

## Examples

### Load remote stylesheet

#### NPM

```javascript
var loadCss = require('stylesheet-inject').load;
loadCss('//example.com/path/to/resource.css', function (error, $link) {
  // error callback with <link/> DOM element provided
});
```

#### CDN

```html
<script src="//unpkg.com/stylesheet-inject/dist/stylesheet-inject.min.js"></script>
<script>
var loadCss = stylesheetInject.load;
loadCss('//example.com/path/to/resource.css', function (error, $link) {
  // error callback with <link/> DOM element provided
});
</script>
```

### Inject raw CSS

#### NPM

```javascript
var injectCss = require('stylesheet-inject').inject;
injectCss(
  'p { color: red; }' +
  'a { color: blue; }'
);
```

#### CDN

```html
<script src="//unpkg.com/stylesheet-inject/dist/stylesheet-inject.min.js"></script>
<script>
var loadCss = stylesheetInject.inject;
injectCss(
  'p { color: red; }' +
  'a { color: blue; }'
);
</script>
```

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