5.0.0 • Published 3 years ago

join-io v5.0.0

Weekly downloads
553
License
MIT
Repository
github
Last release
3 years ago

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.

jsDelivr works in similar way: load Multiple files with a single HTTP request.

How to use?

Join-io could be used as express middleware.

Client

<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.

<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:

<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

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

5.0.0

3 years ago

4.0.0

4 years ago

3.0.2

4 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

7 years ago

1.4.6

7 years ago

1.4.5

7 years ago

1.4.4

8 years ago

1.4.3

8 years ago

1.4.2

9 years ago

1.4.1

9 years ago

1.4.0

9 years ago

1.3.5

9 years ago

1.3.4

9 years ago

1.3.3

9 years ago

1.3.2

9 years ago

1.3.1

9 years ago

1.3.0

9 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.12

10 years ago

1.0.11

10 years ago

1.0.10

10 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago