Why is this important?
What does the Optimization check?
How do you resolve this issue?
As an illustrative point, Lighthouse can identify surplus code on a per-page basis, but it lacks visibility across other pages. Conversely, Sitebulb offers a 'Code Coverage' report showing unused code distribution site-wide:
<!-- Here would be an example or image of the "Code Coverage" in action -->
Tools may not replicate user interactions fully and thus fail to assess all state permutations of a page.
Validating whether code performs ancillary functions, like tracking, is challenging.
Rather than heedlessly removing code due to automated suggestions, it is prudent to involve a developer intimately acquainted with the code. Their task would then be to incrementally refine the code base.