How to remove unused JavaScript and CSS files from my website?
09:13 21 Nov 2025

I’m trying to improve my website performance and Google PageSpeed Insights shows that many JavaScript and CSS files are unused or partially unused.

I want to remove or disable these unnecessary files, but I’m not sure what the correct or safest method is.

My setup:

  • Platform: PHP

  • Issue: Unused JS/CSS increasing load time and negatively affecting performance scores

What I want to achieve:

  • Remove or stop loading unused JS/CSS

  • Load only required assets on specific pages

  • Avoid breaking theme functionality

What I have tried:

  • Checking PageSpeed “Remove unused CSS/JS” section

  • Tried disabling some files, but some parts of the site break

  • Searched documentation but did not find a clear solution

javascript php css