Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to reduce the memory and CPU footprint of web pages

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "how to reduce the memory and CPU footprint of web pages", which is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn "how to reduce the memory and CPU footprint of web pages".

Some web pages look small but will be very slow to open, while others are very long but smooth in use, which can be affected by the use of memory and CPU on the user's computer.

Browser problems, have their own browsers to deal with memory problems will affect, but almost can not control, Windows: IE series, refresh recycling is not large, but minimized will release memory. Firefox2 is also said to be minimizing recycling, but I have never seen the most rubbish, using as much as possible, and basically no recycling. It is said that prototype's ajax will also cause memory to increase all the time. Opera is the best. It's always been under control. There is no problem.

The memory allocation mechanism of Linux is different from that of Win. It can be used as much as it can, and it may kill the system if the browser takes up light.

Page problems, the browser to render the page will consume memory and CPU, can reduce a little, reduce the point.

Use DocType structurally to tell the browser what you are using, and html4 also has DTD. Maybe Transitional is more suitable for you if you are using XHTML and can maintain a good structure, remember to output the corresponding MIME and XML header 1, which can reduce the browser's code inspection, keep the structure intact, and don't let the browser help you complete the code. To control the file size of the page, you can remove the indentation that is more comfortable to see the code through the program. 2K is also the size. Iframe will produce a new page, in fact, there are many ways to replace the introduction of iframe JS and CSS can be properly merged, the same background images can also be merged, and even some people even merge Flash to the known width and height of the content picture / Object to add the width attribute to reduce the local re-rendering of the page.

In most cases, only the file size is different from the quality of 99 and 70 jpg. The same is true of gif, especially small icons, the difference between 256colors and 128colors is the file size. Flash moves too fast and eats CPU too much, so controlling the number of frames per second and the effect of animation can be reduced. If the quality is displayed in medium to low, it will save a lot of resources, but this will sacrifice the effect. The quality attribute is sometimes more appropriate to choose Autolow2 or Autohigh. There is no need to low or best all the time. Flash saves file size by using vector graphics, but it takes CPU to calculate complex graphics and animations. If there are too many complex filters, it will take up a lot of memory, and the blur filter will be reduced by 3. IE filters are also memory-intensive and have compatibility issues. The translucency of the full screen eats resources very much. The 2x2 image is about the same size as the 8x8 image, but the tiled background 2x2 takes up a lot more. Gif animation also has the concept of frame, don't think of gif as flash.

Don't introduce the entire pretotype or jQuery in order to use a $() in behavior, they have more functions. AJAX is very handsome. But using xml will use the XML parser, some people recommend using JSON, but if you want to eval the data, you can actually directly import the script of the object. Just pass one more object name, or write the object name dead, or jsonFlickrApi ({"xxx": "xxx"}) like flickr, and use it directly as a function, . When you can solve some effects with visibility:hidden, don't use display:none to play. It is not meaningful to emphasize that js variables should be global and local, and the complexity of JS can not be explained in one or two sentences. Pay attention to the new book that is being published by Moon Shadow. ^ ^

In fact, some of the content here is similar to how to quickly present our web page, but that article is mainly about dealing with the server, but in many cases, it will save the resource consumption of the client as well as the resource consumption of the server.

In fact, this article has been squatting in the draft box for a long time, and there is no time to sort it out. What is given now is not complete, because it is not complete, so add it slowly.

Problem: although it can cause the mode problem of the browser, the problem can be solved. With reference to Serving up XHTML with the correct MIME type, the browser that dispatches XML headers will not be fault-tolerant, and the error structure will cause the whole page to fail to be displayed. Autolow: speed is a priority, but it will also improve the appearance as much as possible. Anti-aliasing is turned off when playback begins. If Flash Player detects that the processor can handle the anti-aliasing feature, it will be turned on.

Autohigh: at the beginning, both playback speed and appearance are emphasized, and appearance will be sacrificed if necessary to ensure playback speed. Anti-aliasing is on when playback begins. If the actual frame rate falls below the specified frame rate, anti-aliasing is turned off to increase playback speed. Use this setting to simulate the Anti-aliasing command (View > Preview Mode > Anti-aliasing). Blur filter: when using blur filters, if the values used for blurX and blurY are integer powers of 2 (for example, 2, 4, 8, 16, and 32), you can speed up the calculation and improve performance by 20 to 30 percent (the help of flash).

The above is all the contents of the article "how to reduce the memory and CPU footprint of web pages". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report