当前位置:网站首页>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 )
边栏推荐
- 揭秘GES超大规模图计算引擎HyG:图切分
- SQL is used for field data types in various databases
- 谈谈CNN中的位置和尺度问题
- Applet request interface encapsulation
- Record Baidu search optimization thinking analysis
- PostgreSQL change table owner
- QQ机器人官方插件加载配置方法【beta2版本】
- Process of vacuum and vacuum full
- Ali vision AI training camp-day01
- MySQL transaction explanation
猜你喜欢

QQ机器人疫情查询/疫情关注等【最新beta2版本】

Google cloud SSH enable root password login
![QQ robot: self forbidden words management of group members [latest beta2 version]](/img/1b/7dcc8ed344c9f62870d76f16b99f1d.png)
QQ robot: self forbidden words management of group members [latest beta2 version]

Google SEO external chain releases 50+ website platform sharing (e6zzseo)

Leetcode-78-subset

wooyun-2014-065513

Cutting feet to fit shoes - talking about the ramp reconstruction on the track

Panda weekly -2022/02/18

Elastic high-performance computing on the cloud supports the rapid development of the life science industry, reducing costs and increasing efficiency

削足适履 - 谈谈赛道上的坡道改造
随机推荐
三、HikariCP获取连接流程源码分析三
QQ robot epidemic situation query / epidemic situation concern [latest beta2 version]
What should I pay attention to in GoogleSEO content station optimization?
PHP FPM, workman, spoole, golang simple performance test
Electronic package to generate EXE file
Simple native JS tab bar switching
Leetcode-101-symmetric binary tree
Automatic fitting when the applet reaches the top
Google SEO external chain releases 50+ website platform sharing (e6zzseo)
Native JS array some method de duplication
Process of vacuum and vacuum full
Yum command
JS get the parameters in the URL link
Apifox simple understanding -- the integrator of web side testing
JS some small problems about adding and accessing values to arrays
6、 Configuration resolution of hikariconfig
请问同花顺开户安全吗?
通过启牛学堂开的股票账户可以用吗?资金安全吗?
Is it safe to open an account with flush?
Network security detection and prevention test questions (I)