Performance is a big word, which you can see everywhere which many layers as Front End, Back End, Infrastructures, Scalable, ... So for this article, I talk the performance thinking on Front End, especially ReactJS which one of the popular UI libraries nowadays.
Disclaimer: As mentioned above, Performance is a huge thing, the article bases on my knowledge and experience so it might not cover everything, feel free to correct me by adding the comment if I was wrong
Let's Performance Thinking as entire Application not only the benchmark
Nowadays you will hear new UI libraries or frameworks with better performance and impressive benchmark which make me have the feeling that libraries have racing about the performance but in the real world, the application is more complicated than only set the count...
References:
- krausest.github.io/js-framewor…
- javascript.plainenglish.io/javascript-…
To clarify, I wouldn't say benchmark is wrong, Benchmark is one of the factors to help us see how library performs on some scenarios but I would suggest that don't take it as the main reason to choose the library/frameworks because nowadays those popular libraries/frameworks have really good performance, most of the time we won't see different which libraries/frameworks should not us care about it.
One of the good things about ReactJS is they have Facebook's environment with billions of users for verification, they will see differences in their matrix performance good or bad after any releases which other libraries/frameworks might figure out the problem after one or two years hence it might be too late and might need to re-build entire libraries/frameworks, AngularJS version 1.xx is a good example.
Performance Thinking and Data Flow are close Friend
Most of the time, I see the reason performance issues or how to improve performance is data flow, the problem of how we manage our state management. When we have good data flow, it is automatic works pretty well because ReactJS is declarative UIs and they are really good at doing their jobs.
Example:
Designing Complicated Form which has a lot of components inside and we also need to collect all information user's selection to submit. At the same time we also re-fill it back when the user wants to edit hence declare defaultValue and value separately state to avoid re-render again. I can have another article in a more detailed Form and different ways how to implement it.ReactJS also has API useMemo, useCallBack to optimize performance so special scenarios but we optimize by moving state around. Here is a good article about it. overreacted.io/before-you-…
Performance Thinking and Caching, Graphql also are close Friend
Caching is hard, I would suggest that you don't need to implement it by yourself unless you have a strong reason. Otherwise, there are some good libraries supporting caching out of the box which you don't need to worry like
- React Query: react-query.tanstack.com
- ApolloGraphQL: www.apollographql.com/docs/react
GraphQL is an interesting topic which we can discuss in another article.
Hope everyone enjoys, I will plan the following topic with more detail and practical example if you guy wants.
常见问题FAQ
- 免费下载或者VIP会员专享资源能否直接商用?
- 本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
- 提示下载完但解压或打开不了?
- 找不到素材资源介绍文章里的示例图片?
- 模板不会安装或需要功能定制以及二次开发?
发表评论
还没有评论,快来抢沙发吧!