In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "the basic principles of JavaScript DOM operation". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Basic principles of JavaScript DOM operation
In Web development, a very important role of JavaScript is to operate on DOM. As we all know, the efficiency of JavaScript DOM operation is very low, and it is not generally slow, and this is one of the common problems that cause performance problems. Why is it slow? Because the changes to DOM affect the user interface of the web page, redrawing the page is an expensive operation. Too many JavaScript DOM operations will lead to a series of redrawing operations, and in order to ensure the accuracy of the execution results, all changes are performed synchronously in sequence. We call this process reflow, and it is one of the most expensive browser operations. Reflow operations mainly occur in several situations:
◆ when adding or deleting a DOM node.
When ◆ dynamically sets a style (such as element.style.width= "10px").
◆ when getting a size value that must be calculated, such as accessing offsetWidth, clientHeight, or other CSS values that need to be calculated (in DOM-compatible browsers, it can be obtained through the getComputedStyle function; in IE, it can be obtained through the currentStyle property).
The key to solving the problem is to limit the number of reflows caused by the JavaScript DOM operation. Most browsers do not update DOM during the execution of JavaScript. Accordingly, these browsers put their operations on DOM into a queue and execute them sequentially after the JavaScript script has been executed. That is, during JavaScript execution, the user cannot interact with the browser until a reflow operation is performed. (the runaway script dialog triggers a reflux operation because it performs an operation that aborts JavaScript execution, and the user interface is updated.)
There are two basic ways to reduce backflow operations due to DOM modifications. * is to do as much preparation as possible before operating on the current DOM. A classic example is to add many DOM nodes to a document object:
For (vari=0;i
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.