Member-only story

Don’t install PDF dependencies, use this.

Bekhzod Ismoiliy
2 min readAug 30, 2024

--

I will show you how to avoid useless dependencies in this silly example.

I remember that day when my PM came to the office and said to everyone that we needed to show a PDF file for viewing on our main page.

I as the lead frontend developer had to fulfill the PM’s wish.

I approached PM's office and asked, “What will the user do with this PDF file?

He replied, “Just read, that’s it”.

Then, I looked up all the dependencies across npm and yarn packages that correspond to the functionality of displaying the PDF file.

Here is the list of what I found in the package manager search.

  1. react-pdf (link)
  2. pdfkit (link)
  3. jspdf-autotable (link)
  4. @react-pdf/renderer (link)
  5. pdfjs-dist (link)

What I found interesting is all of them have a huge bundle size. What I mean is huge.

  1. react-pdf has 3.23 MB
  2. pdfkit has 5.9 MB
  3. jspdf-autotable has 253 kB
  4. @react-pdf/renderer has 2.33 MB
  5. pdfjs-dist has 36.5 MB

I fully agree that jspdf-autotable has the smallest bundle size. However, I came up with a solution that was much more suitable.

The solution is easy as possible.

--

--

Bekhzod Ismoiliy
Bekhzod Ismoiliy

Written by Bekhzod Ismoiliy

I am a highly skilled and dedicated Frontend Web Developer with a passion for creating exceptional user experiences.

Responses (1)