当前位置:网站首页>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 )
边栏推荐
- PostgreSQL change table owner
- Print 1 cute every 100 milliseconds ~ with a running lantern effect
- Google SEO external chain releases 50+ website platform sharing (e6zzseo)
- Error record: preg_ match(): Compilation failed: range out of order in character class at offset 13
- MySQL prompt performance_ Schema missing table
- Tcp/ip test questions (I)
- Android Development Notes - Quick Start (from sqllite to room licentiousness) 2
- Ali visual AI training camp -day03- construction of electronic photo album (face and expression recognition)
- R language plot visualization: plot visualization of two-dimensional histogram contour (basic 2D histogram contour)
- Applet wx Request encapsulation
猜你喜欢
Google cloud SSH enable root password login
Android Development Notes - Quick Start (from sqllite to room licentiousness) 2
DARKHOLE 2
Using flex to implement the Holy Grail layout is as simple as that
Leetcode-78-subset
Genicam gentl standard ver1.5 (1)
广州华锐互动打造VR展厅全景在线虚拟展厅
Apifox simple understanding -- the integrator of web side testing
QQ机器人:群成员自我禁言管理【最新beta2版本】
Connecting PHP to MySQL instances in the lamp environment of alicloud's liunx system
随机推荐
Ali visual AI training camp -day05- creativity day - your image recognition project
广州华锐互动打造VR展厅全景在线虚拟展厅
Applet canvas generate sharing Poster
MySQL prompt performance_ Schema missing table
什么是算子?
云上弹性高性能计算,支持生命科学产业高速发展、降本增效
Leetcode-101-symmetric binary tree
揭秘GES超大规模图计算引擎HyG:图切分
What are Baidu collection skills? 2022 Baidu article collection skills
Solidity date tool
[C language practice - print the upper triangle and its deformation (with blank version)]
Principles of MySQL clustered index and non clustered index
Guangzhou Sinovel interactive creates VR Exhibition Hall panoramic online virtual exhibition hall
PHP FPM, workman, spoole, golang simple performance test
QQ robot flash forwarding / recall message forwarding [latest beta2 version]
ECS 7-day practical training camp (Advanced route) -- day01 -- setting up FTP service based on ECS
Kotlin compose terminate todo project Click to edit and modify todo
RPM package installation command
SEO outsourcing reliable company, enterprise SEO outsourcing company which reliable?
Tcp/ip test questions (III)