当前位置:网站首页>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 )
边栏推荐
- Processing method for uniapp or applet onload not receiving parameters
- R language uses the model of DALEX package_ The profile function interprets the relationship between a continuous feature and the target value Y in multiple classification models based on the conditio
- Validation of TTF font by validator of laravel
- Install spoole
- 2、 Hikaricp source code analysis of connection acquisition process II
- Solidity date tool
- Lilda Bluetooth air conditioning receiver helps create a more comfortable road life
- Trend ea- fixed stop loss and profit per order
- JS mobile phone and computer open different websites
- PostgreSQL user role permissions
猜你喜欢

The native JS mobile phone sends SMS cases. After clicking the button, the mobile phone number verification code is sent. The button needs to be disabled and re enabled after 60 seconds

云上弹性高性能计算,支持生命科学产业高速发展、降本增效

Embark on a new journey and reach the world with wisdom

Process of vacuum and vacuum full

Bindgetuserinfo will not pop up

Paddleocr learning (II) paddleocr detection model training

Vulnhub range - darkhole 1

What should I pay attention to in GoogleSEO content station optimization?

Ali visual AI training camp -day03- construction of electronic photo album (face and expression recognition)

Leetcode-78-subset
随机推荐
PHP little knowledge record
Applet password input box
5、 Initialization analysis II of hikaricp source code analysis
PHP synchronizes website content to hundreds of websites to improve SEO ranking
Can the stock account opened through qiniu school be used? Is the fund safe?
PHP Chinese regular
什么是算子?
Force wechat page font size to be 100%
Ali vision AI training camp-day01
Google SEO external chain releases 50+ website platform sharing (e6zzseo)
Vulnhub range - darkhole 1
JVM | runtime data area (heap space)
Paddleocr learning (II) paddleocr detection model training
QQ机器人疫情查询/疫情关注等【最新beta2版本】
最新數據挖掘賽事方案梳理!
Process of vacuum and vacuum full
通过启牛学堂开的股票账户可以用吗?资金安全吗?
[C language practice - print the upper triangle and its deformation (with blank version)]
Applet canvas generate sharing Poster
为什么生命科学企业都在陆续上云?