# join-io

> Join files on a fly to reduce requests count

Latest version **5.0.0** (published 2021-01-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install join-io
pnpm add join-io
yarn add join-io
bun add join-io
```

## 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 | 5.0.0 |
| Published | 2021-01-25 |
| First published | 2014-08-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=14 |
| Dependencies | 2 |
| Unpacked size | 10.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 79 |
| Author | coderaiser |
| Maintainers | coderaiser |
| Keywords | files, join, request, pipe, express |

## Links

- npm: https://www.npmjs.com/package/join-io
- Repository: https://github.com/coderaiser/join-io
- Homepage: http://github.com/coderaiser/join-io
- Issues: https://github.com/coderaiser/join-io/issues
- npm.io page: https://npm.io/package/join-io

## Dependencies (2)

- [ponse](https://npm.io/package/ponse.md) ^6.0.0
- [files-io](https://npm.io/package/files-io.md) ^4.0.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 5.0.0 (latest) — 2021-01-25
- 4.0.0 — 2020-02-21
- 3.0.2 — 2019-12-16
- 3.0.1 — 2018-10-24
- 3.0.0 — 2018-10-24
- 2.0.2 — 2018-05-02
- 2.0.1 — 2018-05-02
- 2.0.0 — 2017-07-13
- 1.4.6 — 2017-05-24
- 1.4.5 — 2016-11-28
- 1.4.4 — 2016-01-29
- 1.4.3 — 2016-01-28
- 1.4.2 — 2015-10-26
- 1.4.1 — 2015-06-11
- 1.4.0 — 2015-06-04
- … 23 more at https://npm.io/package/join-io/versions

## README

# Join-io

Join files on a fly to reduce requests count.

## Install

`npm i join-io --save`

## How it works?

`join-io` it's middleware that works with streams: open files and pipe them to `response` one-by-one,
when everything is done, stream is closing. `join-io` based on readPipe function of [files-io](https://github.com/coderaiser/files-io "Files-io").

[jsDelivr](https://jsdelivr.com/ "jsDelivr") works in similar way: [load Multiple files with a single HTTP request](https://www.maxcdn.com/blog/jsdelivr-better/ "load Multiple files with a single HTTP").

## How to use?

`Join-io` could be used as express middleware.

### Client

```html
<link rel="/join:/css/normilize.css:/css/style.css">
<script src="/join:/lib/client.js:/lib/util.js:/lib/jquery.js"></script>
```

#### Join.js

You could build join urls dynamically. Load `/join/join.js` library for this purpose.

```html
<script src="/join/join.js"></script>
<script>
    join(['lib/client', 'lib/util.js']);
</script>
```

To decrease requests count you could make `/join/join.js` part of request:

```html
<script src="/join:/lib/client.js:/lib/util.js:/join/join.js"></script>
```

Instead of `/join` you could use any prefix you like (don't forget to set it on the server side).

### Server

```js
const join = require('join-io');
const http = require('http');
const express = require('express');

const app = express();
const server = http.createServer(app);

const port = 1337;
const ip = '0.0.0.0';

app.use(join({
    dir: __dirname,
    prefix: '/join',    /* default */
}));

app.use(express.static(__dirname));

server.listen(port, ip);
```

## License

MIT

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