'Is there any way to delete useless functions in JS libraries?

I'm building a project in javascript, using paper.js in some features. Most of my project is built in vanilla Javascript, just some minimum but important features are built with paper.js

The problem is that the library (.min library) is 200kb. The normal library is 300kb, I was wondering if there is an automatic way to see which functions are being used in the main paper.js library, in order to delete the useless functions. If there is no program or automatic way to do this, maybe some advice of how to do it manually, or which tools you recommend for me and my team in order to delete useless functions, then minify the file and run it smaller.

Thank you all guys, I did not added any specific code because I want this anwser to be global.

Greetings



Solution 1:[1]

You have to do it manually but it's not an easy (and certainly not quick) process. You'll have to find which functions you're using and then find whatever classes or functions those functions reference. You would probably have an easier time creating a new script then copy/pasting what you're using (and any referenced content) then running it with your script, log errors, and repeat.

When you're done there's many minify libraries and services online you can use to minify the new script.

Solution 2:[2]

I used the paper-core version and then minified. I saved 140kb by doing this. There's still no way to see useless functions in this library

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 criticalsession
Solution 2 Luis Olivárez