Search code examples
javascriptreactjsnext.jscode-splitting

Next.JS unused javascript slow performance


I am doing my first website with Next.Js and after I do the lighthouse test I get really bad performance score. It says it is for unused JavaScript. Those files are in the chunk folder. I read a lot that I should split that code in order to make the page faster, but I couldn.t find a anything about how to do it. If there is someone that knows about it, it would be a great help. Below is a screenshot of the lighthouse: enter image description here

enter image description here


Solution

  • Delete all chunks and generated code, then do a production build using npm run build instead of npm run dev when you're running it on a live server.