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

Problem with unused library functions #19

Closed
hcvazquez opened this issue Dec 23, 2016 · 1 comment
Closed

Problem with unused library functions #19

hcvazquez opened this issue Dec 23, 2016 · 1 comment
Labels
🙋 no/question This does not need any changes

Comments

@hcvazquez
Copy link

My name is Hernan; with a group of colleagues we are conducting a research about unused code present in dependencies of JavaScript projects. We call this functions, UFF (Unused foreign functions). We found that in most projects there exist a great amount of UFF that are being included in the final bundle.

In the case of unified (v 5.1.0) our tools detected approximately 25 unused function in dependencies. Removing those functions, the size of unified bundled could be reduced at least 10% (All tests passed). I’m attaching the reduced version of your project.
unified(optimized).txt

I’ll be very grateful if you can answer me the following questions:
-Did you were aware of the existence of these unused functions in your projects?
-Do you think that this is a problem?
-Do you think that can be useful a tool for deal with this kind of problem?

Thanks in advance.

Cheers,

@wooorm
Copy link
Member

wooorm commented Dec 23, 2016

Highly probable, yes.

This research is kind-off useless to me though, because:

a) I have no idea which functions your algorithm removed;
b) Unified will never be dropped in on its own, always used with other modules, which probably do use some of those functions.

To answer your questions:

-Did you were aware of the existence of these unused functions in your projects?

I’ve rewritten some parts to reduce that amount. Such as including some parts of Node’s pipes internally. I kinda think 10% is nice. But I’d love to know what you did to

-Do you think that this is a problem?
-Do you think that can be useful a tool for deal with this kind of problem?

No, such fixes should be implemented in a build step, not by libraries such as this.

UPDATE

I checked more in depth, and it seems:

  • polyfills are removed, which are in place to deal with different user agents and should not be removed;
  • function replaceExt, function location, and some setters are erroneously removed, the whole function bodies are stripped!

From what I gather you use the tests of unified to check the bundle. However, dependencies also have tests and those tests don’t need to be added to unified itself. Those tests are not included in your algorithm though.

You’re testing the wrong thing. 10% isn’t true.

@wooorm wooorm closed this as completed Dec 23, 2016
@wooorm wooorm added the 🙋 no/question This does not need any changes label Aug 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 no/question This does not need any changes
Development

No branches or pull requests

2 participants