Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust 'grabfood-bundle-size' post #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions _posts/2021-07-29-grabfood-bundle-size.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ I: Large dependencies (fairly obvious, because the box size will be large)

II: Duplicate dependencies (same library that is bundled multiple times across different assets)

![](img/grabfood-bundle/image2.png)![](img/grabfood-bundle/image2.png)
![](img/grabfood-bundle/image2.png)

III: Dependencies that look like they don’t belong (e.g. Why is ‘elliptic’ in my frontend bundle?)

Expand All @@ -73,13 +73,14 @@ What to avoid:
* E.g. Small node dependencies

### Step B: Investigate the Usage of Your Dependencies (Where are my Dependencies Used?)
In this step, we are trying to answer this question: “Given a dependency, which files and features are making use of it?”.

<div class="post-image-section"><figure>
<img src="/img/grabfood-bundle/image10.png" alt="Our grabfood.com bundle analyzer output" style="width:90%"> <a href="https://pixabay.com/photos/architecture-building-geometric-1868547/"><figcaption align="middle"><i>Image source</i></figcaption></a>
</figure>
</div>

In this step, we are trying to answer this question: “Given a dependency, which files and features are making use of it?”.

There are two broad approaches that can be used to identify how our dependencies are used:

I: Top-down approach: “Where does our project use dependency X?”
Expand All @@ -105,13 +106,14 @@ Don’ts:
* Stick to a single approach - Know when to switch between Top-down and Bottom-up approaches to narrow down the search space.

### Step C: Reducing Your Dependencies
Now that you know what your largest dependencies are and where they are used, the next step is figuring out how you can shrink your dependencies.

<div class="post-image-section"><figure>
<img src="/img/grabfood-bundle/image15.gif" alt="Our grabfood.com bundle analyzer output" style="width:90%"> <a href="https://i.imgur.com/w8Ydzvb.gif"><figcaption align="middle"><i>Image source</i></figcaption></a>
</figure>
</div>

Now that you know what your largest dependencies are and where they are used, the next step is figuring out how you can shrink your dependencies.

Here are 7 strategies that you can use to reduce your dependencies:

1. [Lazy load large dependencies and less-used dependencies](#1-lazy-load-large-dependencies-and-less-used-dependencies)
Expand Down