There's a particular kind of developer confidence that makes you think writing everything yourself is a good idea.
Sometimes it is.
Other times, you're spending an afternoon implementing something that an established open-source library has already handled for years.
I recently went through an open-source audit of Pocket PDF, my browser-based file tools project.
The goal wasn't to replace everything with dependencies.
It was to identify where I was maintaining custom implementations without getting anything meaningful in return.
I ended up replacing several hand-rolled implementations while keeping the browser-native functionality thatThere's a particular kind of developer confidence that makes you think writing everything yourself is a good idea.
Sometimes it is.
Other times, you're spending an afternoon implementing something that an established open-source library has already handled for years.
I recently went through an open-source audit of Pocket PDF, my browser-based file tools project.
The goal wasn't to replace everything with dependencies.
It was to identify where I was maintaining custom implementations without getting anything meaningful in return.
I ended up replacing several hand-rolled implementations while keeping the browser-native functionality that was already doing its job.
Here's what changed.
- Password strength: zxcvbn
Password-strength estimation is more complicated than counting characters.
A password with twelve characters isn't automatically strong. Common patterns, dictionary words, repeated sequences and predictable substitutions all matter.
I replaced my custom password-strength logic with zxcvbn.
It provides a more established approach to estimating password strength and identifying predictable password patterns.
The important distinction is that password strength estimation isn't the same thing as password security.
A strength meter doesn't guarantee that a password is safe, and it shouldn't pretend to.
I wanted a better estimator, not a magical security certificate.
- CSV processing: Papa Parse
CSV looks simple until you encounter actual CSV files.
Commas inside quoted fields, escaped quotes, line breaks and inconsistent records can turn a quick split-based implementation into a collection of edge cases.
I switched the CSV pair to Papa Parse.
It handles the parsing work instead of requiring me to keep expanding custom string-processing logic.
This is a good example of where a dependency makes sense.
CSV is a defined format with enough real-world variations that a mature parser is more useful than another homemade implementation.
- ZIP handling: fflate
ZIP processing needed more than basic compression and extraction.
I moved the ZIP functionality to fflate.
But there was an additional security requirement: archive bomb protection.
A ZIP file can be relatively small while containing entries that expand into enormous amounts of data.
Simply checking the final extracted size is too late if you've already started inflating everything.
So I added a central-directory scan.
Before inflating entries, the application inspects archive metadata and enforces size limits.
This allows it to reject archives that exceed the configured limits before attempting extraction.
I also added encrypted-entry detection.
An encrypted ZIP entry shouldn't be treated like an ordinary file that can simply be extracted without the required password or decryption support.
These checks are important because replacing a custom implementation with an open-source library doesn't automatically solve every security problem.
You still need to understand how you're using that library.
- HTML entities: he
I also replaced custom HTML entity handling with he.
Entity encoding and decoding has plenty of small details that are easy to overlook.
Using a dedicated library means I don't need to keep maintaining a homemade collection of replacements and special cases.
It's not the most exciting change, but that's kind of the point.
Some code is better when you don't have to think about it anymore.
What I deliberately didn't replace
Not everything needs a library.
I kept several browser-native implementations:
Canvas-based image operations.
Web Crypto functionality.
DOM-based tools.
Why?
Because the browser already provides mature APIs for these jobs.
Adding a dependency just to wrap a native API would increase the maintenance surface without necessarily improving the result.
For example, Canvas already provides the image manipulation primitives I need. Web Crypto provides cryptographic functionality directly through the browser.
A dependency should solve a real problem, not just make the package list look more impressive.
The bugfixes after the migration
The audit also uncovered an unrelated issue in five tools.
Their preview-resolution export behaviour was broken.
The preview looked correct, but the exported result didn't consistently respect the intended resolution.
This is one of those bugs that can survive for a while because the visual preview creates the impression that everything is working.
I fixed those export paths during the cleanup.
It was a useful reminder that dependency audits shouldn't be limited to checking whether a new package works.
You also need to test the complete operation, including the final output.
My rule for adding dependencies now
I'm not against writing custom code.
I'm against maintaining custom code without a good reason.
If a mature library handles a well-defined problem better, I'll seriously consider using it.
If the browser already provides a reliable API, I'll probably keep using that.
And if a dependency introduces security or performance concerns, I'll evaluate those too.
Open source isn't automatically safer or better. It's simply another implementation that deserves proper evaluation.
When you're building a project, what's your threshold for replacing your own implementation with an established open-source library? was already doing its job.
Here's what changed.
- Password strength: zxcvbn
Password-strength estimation is more complicated than counting characters.
A password with twelve characters isn't automatically strong. Common patterns, dictionary words, repeated sequences and predictable substitutions all matter.
I replaced my custom password-strength logic with zxcvbn.
It provides a more established approach to estimating password strength and identifying predictable password patterns.
The important distinction is that password strength estimation isn't the same thing as password security.
A strength meter doesn't guarantee that a password is safe, and it shouldn't pretend to.
I wanted a better estimator, not a magical security certificate.
- CSV processing: Papa Parse
CSV looks simple until you encounter actual CSV files.
Commas inside quoted fields, escaped quotes, line breaks and inconsistent records can turn a quick split-based implementation into a collection of edge cases.
I switched the CSV pair to Papa Parse.
It handles the parsing work instead of requiring me to keep expanding custom string-processing logic.
This is a good example of where a dependency makes sense.
CSV is a defined format with enough real-world variations that a mature parser is more useful than another homemade implementation.
- ZIP handling: fflate
ZIP processing needed more than basic compression and extraction.
I moved the ZIP functionality to fflate.
But there was an additional security requirement: archive bomb protection.
A ZIP file can be relatively small while containing entries that expand into enormous amounts of data.
Simply checking the final extracted size is too late if you've already started inflating everything.
So I added a central-directory scan.
Before inflating entries, the application inspects archive metadata and enforces size limits.
This allows it to reject archives that exceed the configured limits before attempting extraction.
I also added encrypted-entry detection.
An encrypted ZIP entry shouldn't be treated like an ordinary file that can simply be extracted without the required password or decryption support.
These checks are important because replacing a custom implementation with an open-source library doesn't automatically solve every security problem.
You still need to understand how you're using that library.
- HTML entities: he
I also replaced custom HTML entity handling with he.
Entity encoding and decoding has plenty of small details that are easy to overlook.
Using a dedicated library means I don't need to keep maintaining a homemade collection of replacements and special cases.
It's not the most exciting change, but that's kind of the point.
Some code is better when you don't have to think about it anymore.
What I deliberately didn't replace
Not everything needs a library.
I kept several browser-native implementations:
Canvas-based image operations.
Web Crypto functionality.
DOM-based tools.
Why?
Because the browser already provides mature APIs for these jobs.
Adding a dependency just to wrap a native API would increase the maintenance surface without necessarily improving the result.
For example, Canvas already provides the image manipulation primitives I need. Web Crypto provides cryptographic functionality directly through the browser.
A dependency should solve a real problem, not just make the package list look more impressive.
The bugfixes after the migration
The audit also uncovered an unrelated issue in five tools.
Their preview-resolution export behaviour was broken.
The preview looked correct, but the exported result didn't consistently respect the intended resolution.
This is one of those bugs that can survive for a while because the visual preview creates the impression that everything is working.
I fixed those export paths during the cleanup.
It was a useful reminder that dependency audits shouldn't be limited to checking whether a new package works.
You also need to test the complete operation, including the final output.
My rule for adding dependencies now
I'm not against writing custom code.
I'm against maintaining custom code without a good reason.
If a mature library handles a well-defined problem better, I'll seriously consider using it.
If the browser already provides a reliable API, I'll probably keep using that.
And if a dependency introduces security or performance concerns, I'll evaluate those too.
Open source isn't automatically safer or better. It's simply another implementation that deserves proper evaluation.
When you're building a project, what's your threshold for replacing your own implementation with an established open-source library?
Top comments (0)