How to minimize the "Minimize main-thread work" in nextjs? #19436
Replies: 13 comments 5 replies
-
same... |
Beta Was this translation helpful? Give feedback.
-
me too... |
Beta Was this translation helpful? Give feedback.
-
Is there any solution this? Website is overall good in desktop but not in mobile |
Beta Was this translation helpful? Give feedback.
-
Every project will have a different solution. It's not next.js fault, but the way PageSpeed Insights work. This project of mine here, I know the video is causing the issue: https://neymar-new.ideias.dev/en It's not worthed to bother improving though. And if the user has a fast and good experience, web vitals will not have any impact on SEO results. They are just part of the overall equation. |
Beta Was this translation helpful? Give feedback.
-
Hi! I'm not sure about what you said.
As you said it's a part of the equation to have a good referal but based on my research on a lot of forum, webSite experts, etc... look like the performance is a big part of it. For example if you web site take 5 seconds to load. Most of your users will leave the web site before his finished to load and you lose some referal so maybe (very big maybe) the performance is not the primary standard to have a good SEO and best practises but because of the performance you can loose your audimate because you site take too long time to render so it's impact your refreral... So the performance is sometime set apart but it's kind of second point which impact your referal directly. |
Beta Was this translation helpful? Give feedback.
-
any update on this guys? |
Beta Was this translation helpful? Give feedback.
-
i'm also looking for this. |
Beta Was this translation helpful? Give feedback.
-
Looking for this too! Too much javascript being loaded by nextjs, even with everything fully optimized🫠 |
Beta Was this translation helpful? Give feedback.
-
Would https://nextjs.org/docs/messages/large-page-data affect script evaluation time? |
Beta Was this translation helpful? Give feedback.
-
performance drop in mobile only |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Minimizing main-thread work might sound abstract, but it essentially refers to reducing the workload on the main thread within the renderer process. To clarify, the renderer process is responsible for managing everything inside a browser tab where a website is displayed. Within the renderer process, there are various threads, including the worker thread, compositor thread, and rasterizer thread. However, the majority of the code execution occurs on the main thread. The main thread is responsible for parsing HTML, executing JavaScript, and building the DOM. Therefore, when we talk about minimizing main-thread work, it translates to reducing rendering time. But how can we achieve this? One effective way is by choosing an appropriate rendering method, such as CSR (Client-Side Rendering), SSR (Server-Side Rendering), or SSG (Static Site Generation). The key difference between these methods lies in who is responsible for building the main DOM: JavaScript or the server. For instance, if you use CSR, the main DOM is built by JavaScript on the client side. This means users cannot see the main content until the JavaScript executes. Consequently, if there is a large amount of JavaScript to process, the rendering time will increase significantly. IPC is inter process communication. So, how can we reduce JavaScript bundles? There are several options available. If you’re using React, tools like Webpack (a popular bundler) already provide optimizations for your bundles. However, there’s still room for further improvements. One effective approach is to analyze which components take a long time to execute. Consider whether those components are truly necessary for the first content paint. If not, you can postpone their loading. A great way to achieve this is by using dynamic imports, which allow you to load JavaScript modules only when they are needed. This helps minimize the initial bundle size and improves the time to first content paint (FCP). By dynamically importing only the essential parts of your JavaScript bundle for the initial load, you can significantly improve the overall performance of your application. reference: https://www.sciencedirect.com/science/article/abs/pii/S0166531622000049 |
Beta Was this translation helpful? Give feedback.
-
Another thing that made a fairly big difference in Script Evaluation was migrating away from @emotion for CSS. Emotion bundles the CSS into the JavaScript. I migrated to CSS Modules but other solutions like Tailwind or Vanilla Extract also will not bundle the CSS into JS modules. |
Beta Was this translation helpful? Give feedback.
-
My next js website is very slow on mobile, how can i improve it's speed for mobile.
Beta Was this translation helpful? Give feedback.
All reactions