Skip to content

Commit

Permalink
Add docs about the webpack approach
Browse files Browse the repository at this point in the history
  • Loading branch information
iamakulov committed Mar 8, 2018
1 parent 9c4da1a commit 1e40422
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Expand Up @@ -14,6 +14,7 @@ For Documentation, visit <https://caolan.github.io/async/>

*For Async v1.5.x documentation, go [HERE](https://github.com/caolan/async/blob/v1.5.2/README.md)*

## Usage

```javascript
// for use with Node-style callbacks...
Expand Down Expand Up @@ -48,3 +49,23 @@ async.mapLimit(urls, 5, async function(url) {
console.log(results)
})
```

## Usage in browser with webpack

To keep the bundle as small as possible, don’t import the whole library. Import only methods you use instead.

```javascript
// ❌ DON’T:
import async from 'async';
async.mapLimit(urls, 5, async function(url) {
const response = await fetch(url)
return response.body
})

// ✔ DO:
import { mapLimit } from 'async';
mapLimit(urls, 5, async function(url) {
const response = await fetch(url)
return response.body
})
```

0 comments on commit 1e40422

Please sign in to comment.