---
title: "Comment by Pavel Denisjuk on \"How we reduced our NodeJs app size on AWS Lambda by over 80% 😮\" | Hashnode"
description: "Other things to consider, which work great for us at Webiny, are: 1) Use webpack to bundle your handlers. With this you only get production dependencies that yo"
url: "https://hashnode.com/posts/how-we-reduced-our-nodejs-app-size-on-aws-lambda/613724b7ef28811d8bed6944/comment/613899988b7ef170483a0f0f"
---

[Discussion](https://hashnode.com/posts/how-we-reduced-our-nodejs-app-size-on-aws-lambda/613724b7ef28811d8bed6944)

Comment [How we reduced our NodeJs app size on AWS Lambda by over 80% 😮](https://hashnode.com/posts/how-we-reduced-our-nodejs-app-size-on-aws-lambda/613724b7ef28811d8bed6944)

[Pavel Denisjuk](https://hashnode.com/@pavel910)

[Sep 8, 2021](https://hashnode.com/posts/how-we-reduced-our-nodejs-app-size-on-aws-lambda/613724b7ef28811d8bed6944/comment/613899988b7ef170483a0f0f)

Other things to consider, which work great for us at Webiny, are:

1) Use webpack to bundle your handlers. With this you only get production dependencies that you _actually use in code_ without even thinking about it, + everything gets minified, which greatly reduces the handler size. This also provides the benefit of using tools to analyze your webpack bundle to identify large dependencies and potentially get rid of them.

With webpack it's easy to exclude any module (like `aws-sdk`) from the bundle, using the `externals` parameter. This brings us to the next point:

2) Extract dependencies you share in multiple handlers into [Lambda Layers](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html). Layers can contain both 3rd party npm modules as well as your own project level packages. Once the layer is attached to your Lambda, you import those dependencies as any other node module.

If you use this approach, you don't need to worry about accidentally leaving `aws-sdk` in the production dependencies, because webpack will exclude it anyway. And you can also exclude all the dependencies that will be provided by the Lambda Layers.
