首页 > web前端 > js教程 > How to approach for performance optimisation

How to approach for performance optimisation

DDD
发布: 2024-09-13 20:15:32
原创
773 人浏览过

How to approach for performance optimisation

The purpose of this page is to offer more advice on how to handle the problem of performance optimization for production websites.

It appears that you attempted to divide the bundle chunks on the react production website using React.lazy} andsuspense} in React; however, this did not result in the anticipated improvement in your web performance score.

But why is it the case?

Given that something extra was needed for your production website.....

I was recently assigned a duty to enhance the performance of the production website. I initially thought that we should load each route more lazily, but I soon realised that this had already been done.

I had also begun to wonder what might come next.

I installed the webpack bundle anlyzer plugin and attempted to analyze each piece after that. Following that, I had a lot of suggestions about how to enhance the performance.

Main.bundle.js
main bundle size was too big which is causing increase in downloading time along with parsing time.

How to break the main.bundle.js?
in my case mine main bundle has lot of json which is related to translation which was increasing 1.5 MB of main bundle size.

I did took away translation using lazy import from main.js bundle. This gives 40% performance score optimisation. but this not done yet since we reached from lighthouse performance score 25 to 35 only.

then i started looking at other potential big files.

One of them is moment js, which has numerous locales that we weren't using for our website. Replacing moment js with a lightweight library is one way to fix this, but doing so will require more code modifications and increase my workload testing the entire website—something I hadn't done before—which could lead to more errors. then I made the decision to figure out how to get rid of those undesirable regions; fortunately, a webpack plugin was already available. I was able to minimize the size of the moment.js file by utilizing that plugin [ContextReplacementPlugin].

Stay tuned many more will about to come... Thank you

以上是How to approach for performance optimisation的详细内容。更多信息请关注PHP中文网其他相关文章!

来源:dev.to
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板