What you are referring to is called tree shaking. Without having seen any of your js, it's hard to give suggestions. But if you Google that term you should find several guides
Sep 5, 2022
8
Level 1
How to remove unused JS?
Hello Dears,
..../landing-critical.js?id=186d63f8d2297677a0f1a599114ba49c%20defer JS (per function) 93 244 53 186 57%
....jqueryjquery.min.js?id=8fb8fee4fcc3cc86ff6c724154c49c42%20defer JS (per function) 89 456 31 588 35.3%
JS (per function) 59 950 9391.6%
.../jquery-modal/jquery.modal.min.js?id=a3c73f5af9f3f18fea45b4181a754d03 JS (per function) 4 893 76215.6%
I have 53%, 35% unused javascript. How can I ignore that. I use webpack mix and laravel 8.
Level 102
@md_imran Yes but it does not work quite the same as css. Css is simple as it simply checks if the class is in use. Js is more complex and require that you tell it exactly what you want. This is what is called tree shaking as I mentioned before.
I dont think there exist a purge-js plugin (I have never seen one)
Please or to participate in this conversation.