# astro-preload

> Download images at build time! Supports Iconify icons and arbitrary images.

Latest version **1.1.2** (published 2023-07-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install astro-preload
pnpm add astro-preload
yarn add astro-preload
bun add astro-preload
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2023-07-01 |
| First published | 2023-06-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 7.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 38 |
| Author | Liam Garriga |
| Maintainers | lyonsyonii |
| Keywords | astro, astro-component, astro-integration, image, images, icon, icons, iconify, preload, fetch |

## Links

- npm: https://www.npmjs.com/package/astro-preload
- Repository: https://github.com/lyonsyonii/astro-preload
- Homepage: https://github.com/lyonsyonii/astro-preload#readme
- Issues: https://github.com/lyonsyonii/astro-preload/issues
- npm.io page: https://npm.io/package/astro-preload

## Alternatives

- [@fortawesome/react-fontawesome](https://npm.io/package/@fortawesome/react-fontawesome.md) — 2.2M weekly downloads
- [roboto-fontface](https://npm.io/package/roboto-fontface.md) — 196.0K weekly downloads
- [@react-native-vector-icons/common](https://npm.io/package/@react-native-vector-icons/common.md) — 150.4K weekly downloads
- [stockfish](https://npm.io/package/stockfish.md) — 27.0K weekly downloads
- [@procore/core-icons](https://npm.io/package/@procore/core-icons.md) — 4.6K weekly downloads

## Recent versions

- 1.1.2 (latest) — 2023-07-01
- 1.1.1 — 2023-06-10
- 1.1.0 — 2023-06-10
- 1.0.1 — 2023-06-09
- 1.0.0 — 2023-06-09

## README

# Astro Preload
Easily download images at build time!  
Supports [Iconify](https://icon-sets.iconify.design/) icons and arbitrary images.

## What does it do?
At build time, Astro Preload downloads the images from the provided urls and saves them to `public/assets/preloaded/`.

Can be useful in combination with tools like [astro-compress](https://github.com/astro-community/astro-compress) or to avoid including remote assets at runtime.

> In `development` mode Astro Preload will forward the urls directly, to avoid downloading the files multiple times.

## Install
```bash
npm run astro install astro-preload
# or
yarn astro add astro-preload
```

Remember to move the integration import function before any other imports.

```mjs
import { defineConfig } from "astro/config";
import compress from "astro-compress";
import preload from "astro-preload";

export default defineConfig({
  integrations: [preload(), compress()]
});
```

## Usage
Get icon from Iconify:
```astro
---
import { Icon } from "astro-preload/components";
---
<!-- Automatically fetches and downloads Material Design Icon's "github" SVG -->
<Icon pack="mdi" name="github" />

<!-- Equivalent shorthand -->
<Icon name="mdi:github" />

```

Get image from arbitrary URL:

```astro
---
import { Image } from "astro-preload/components";
---
<!-- Automatically fetches and downloads image -->
<Image url="https://examplecat.com/cat.png" />
```

## API
The **Icon** component accepts the following props:
- `name`: The name of the icon. Follows the format `<pack>:<name>`.
- `pack`: The pack of the icon. Can be skipped if a name with shorthand is provided.
- `size`: The size of the icon. Applied to both `width` and `height`.
- `url`: The URL of the icon. Overrides default Iconify URL.

The **Image** component accepts the following props:
- `name`: The name of the image. If not provided it will try to inferred from the url.
- `url`: The URL of the image.
- `size`: The size of the image. Applied to both `width` and `height`.

Any other props are passed to the wrapped `<img>` tag.

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