当前位置:网站首页>Browser performance optimization (19)
Browser performance optimization (19)
2022-06-25 19:44:00 【Bobo is Bobo】
There are three main points :
① Reduce to HTTP The number and size of requests for
② Code optimization
③dns And HTTP communication mode
Illustrate with examples :
1.js Reduce the use of closures in ( reason : Closures generate stack memory that is not put in )
a: When the loop binds the element to an event , Try to put the information you need later ( Columns such as index )
Stored in the element's custom attributes , Instead of creating a closure store
b. You can form a closure on the outermost layer , Store some public information needed later , Instead of every hair creating a closure ( For example, singleton mode )
c. Manually release the memory not used by the station as much as possible
2. Try to reduce css and js file ( Introduce what needs to be introduced css Merge into one ,js It is also merged into one ), The principle is to reduce http Number of requests , Try to compress the combined code as much as possible ,
Reduce http The size of the requested resource
a:webpack This build tool
b: In mobile development ( Or high performance pc Development ), If js and css Not many , We can write inline
3. Try to use vector diagram or svg Icons instead of traditional png Wait for the format of the picture
4. Reduce to DOM The operation of ( Mainly to reduce DOM Redraw and reflow ( rearrangement ))
a: Separate reading and writing about rearrangement
b: Use document fragments or payment channel splicing to make payment channel binding
5. stay js Avoid “ Nested loop ”( This will add many cycles to the Zheng family ) and “ Dead cycle ”
6. Lazy loading with pictures ( Delay loading ), The purpose is to reduce the number of pages loaded for the first time http Number of requests
7. Using browser and server caching technology (304 cache ), Cache some static resources that are not updated frequently (css、js、 Static pictures can be cached ) The principle is also to reduce http Request size
8. Use event delegates... Whenever possible ( Event agent ) To handle event binding operations , Reduce DOM Frequent operation of , This includes each DOM Element for event binding
9. Reduce use css expression (expression)
10. Minimize the use of label selectors (css The selector is parsed from right to left )
11.css Sprite chart technology (css sprite/css Image wizard ) Put all the smaller pictures together on a big picture , Display the corresponding small icon by positioning
12. Reduce cookie Use ( Mainly to reduce local cookie Storage content size )
13. Data acquisition in the page adopts asynchronous programming and delayed batch loading
14. Video and audio tags appear in the page , We don't want to load these resources when the page loads ( Otherwise the load will slow down )( Just set up preload="none" that will do ) Wait for the page to load , When the audio is playing, we load the resources
15. When the client and server interact , As far as possible, we are based on json Format to transmit (json The format of data processing is convenient , Small resources ) be relative to xml Format transmission will have this advantage
16. As far as possible js Encapsulation ( Low coupling and high cohesion ), See the redundancy code in the page ( Reduce HTTP The size of the requested resource )
17. stay css Minimize the use of @import Import type , because @import It's a synchronous operation , and link Is asynchronous operation
18. Use window.requestAnimationFrame(js Frame animation in ) Instead of the traditional timer animation
19. Reduce the use of recursion , Avoid dead recursion , Avoid stack memory nesting due to recursive functions ( Tail recursion is recommended )
边栏推荐
- Many varieties of EA can be used
- MySQL view explanation
- 3、 Hikaricp source code analysis of connection acquisition process III
- 1、 Hikaricp source code analysis of connection acquisition process I
- On location and scale in CNN
- Tcp/ip test questions (V)
- DARKHOLE 2
- Guangzhou Sinovel interactive creates VR Exhibition Hall panoramic online virtual exhibition hall
- shell-跳出循环-shift参数左移-函数的使用
- [C language practice - print the upper triangle and its deformation (with blank version)]
猜你喜欢

广州华锐互动VR全景为各行各业带来发展

Leetcode-78-subset

New features of php7

DARKHOLE 2

【历史上的今天】6 月 25 日:笔记本之父诞生;Windows 98 发布;通用产品代码首次商用

Gbpnzd firm offer for 14 months, simulation for 19 months, test stable

Ali visual AI training camp -day05- creativity day - your image recognition project

Tiger DAO VC产品正式上线,Seektiger生态的有力补充

最新数据挖掘赛事方案梳理!

为什么生命科学企业都在陆续上云?
随机推荐
Why are life science enterprises on the cloud in succession?
Many varieties of EA can be used
PostgreSQL division considerations
Google SEO external chain releases 50+ website platform sharing (e6zzseo)
PHP little knowledge record
shell-跳出循环-shift参数左移-函数的使用
Solidity date tool
Elastic high-performance computing on the cloud supports the rapid development of the life science industry, reducing costs and increasing efficiency
Connecting PHP to MySQL instances in the lamp environment of alicloud's liunx system
Solve the problem that sublime Text3 package control cannot install plug-ins
6、 Configuration resolution of hikariconfig
DataX script task development record
Network security detection and prevention test questions (II)
User management and permissions
最新数据挖掘赛事方案梳理!
广州华锐互动打造VR展厅全景在线虚拟展厅
2、 Hikaricp source code analysis of connection acquisition process II
Process of vacuum and vacuum full
SEO outsourcing reliable company, enterprise SEO outsourcing company which reliable?
[today in history] June 25: the father of notebook was born; Windows 98 release; First commercial use of generic product code