Mark Davis
Microsoft Corporation
Summary: This article describes the significant performance impact of some of the DHTML features and provides some tips for improving the performance of DHTML pages.
Directory
Brief introduction
Batch processing of DHTML changes
Using innertext
To add a single element using the DOM
Extending options in a SELECT element
Updating tables with the DOM
Write once, use multiple times
Do not use dynamic properties too much
Data binding is effective
Do not set the
DHTML page performance improvement Abstract: This article describes the significant impact of some DHTML functions on the performance, and provides some tips to improve DHTML page performance.
Directory
Introduction
Batch Process DHTML changes
Use innerText
Use DOM to add a single element
Extend the options in the SELECT Element
Update a table with DOM
Write Once, use multiple times
Do not use dynamic attributes too much
Data Binding is very effective
Do not set the
' }); $.data (obj) //Object {name1: "Aaron1", Name2: "Aaron1"} Attaching data to DOM ElementWe use the simplest code to illustrate the process of this process:1. Get the node bodyvar $body = $ ("Body")2. Add a piece of data to the body, the property is Foo, and the value is 52$body. Data ("foo", 52);3. Remove Foo$body. Data (' foo ')Consider a problem:An element can normally be removed by using the. Remove () method, and the respective data is purged. However, for local objects, this
references through the garbage collector (GC), but some unknown factors may prevent the release of resources from the environment. For ie, the status of some DOM object instances is unknown to the script. The following are their basic principles:
Figure 1: Basic cyclic Reference Model
The leakage caused by this model is based on the reference count of COM. The script engine object maintains reference to the DOM object and waits for all references to be removed before the DOM object point
Abstract: This article describes the significant impact of some DHTML functions on the performance, and provides some tips to improve the performance of DHTML pages.
Directory
IntroductionBatch Process DHTML changesUse innerTextUse DOM to add a single elementExtend the options in the SELECT ElementUpdate a table with DOMWrite Once, use multiple timesDo not use dynamic attributes too muchData Binding is very effectiveDo not set the expando attribute i
corresponding number in the cache pool, and do the operation.
General ideas to finish, then to analyze the specific ideas:
In jquery, there is a data constructor that generates an instance whenever the constructor is run.
jquery automatically generates two data instances by default:
var datapriv = new Data () jquery Private, we try not to operate on this instance.
var datauser = new data () This is the service to the user, we use the Data () method is to operate on this instance.
All data
cannot accept the data cache, which are marked in the NoData object. Dom types that cannot accept the data cache as long as the DOM object node name and the corresponding attribute conform to the noData set rule are: ' var match = jquery.nodata[elem.nodeName.toLowerCase ()]; ', The corresponding Acceptdata () method returns FALSE. for DOM objects that accept data caching, the data for each object is cached in the global cache object Jquery.cache, not in the DOM object itself! This is the key p
values. This is especially true for positional attributes.
Tip 8: Restrict the use of dynamic properties.
Data binding is effective
Data binding (English) is a powerful feature that enables you to bind the results of a database query or the contents of an XML data island to HTML elements on a Web page. Instead of returning to the server to extract data, you can provide data sorting and filtering capabilities, as well as different views of the data. Imagine a Web page
following JScript behaviors are triggered:· All variables must be declared.· The function becomes a constant.· Internal objects cannot have the expando attribute.· Internal object attributes cannot be listed or changed.· The arguments object is unavailable.· You cannot assign values to read-only variables, fields, or methods.· The eval method cannot define identifiers within a closed range.· The eval method executes scripts in a restricted security c
Abstract: This article describes the significant impact of some DHTML functions on the performance, and provides some tips to improve the performance of DHTML pages.DirectoryIntroductionBatch Process DHTML changesUse innerTextUse DOM to add a single elementExtend the options in the SELECT ElementUpdate a table with DOMWrite Once, use multiple timesDo not use dynamic attributes too muchData Binding is very effectiveDo not set the expando attribute in t
type of code that is allowed, programs can be more efficient and execute faster. However, some of the features available in previous versions are not available in quick mode. Most of these features are incompatible with multi-threaded applications and make generationCode inefficiencies. For programs compiled with the command-line compiler, you can turn off quick mode and take advantage of full backward compatibility. Note that code compiled in this way runs slower and is less fault tolerant. Fa
Mode
In quick mode, the following JScript behavior is triggered:
· All variables must be declared.
· The function becomes a constant.
· Internal objects cannot have expando properties.
· You cannot list or change the properties of an internal object.
· The arguments object is not available.
· You cannot assign a value to a read-only variable, field, or method.
· The Eval method cannot define identifiers within the enclosing scope.
· The Eva
(element, [key], [value]) does not overwrite any object bound to it. Is that true? Let's study their source code.First look at jQuery. data (element, [key], [value]) source code.Js Code:Copy codeThe Code is as follows:JQuery. extend ({Cache :{},// Please use with cautionUuid: 0,// Unique for each copy of jQuery on the page// Non-digits removed to match rinlinejQueryExpando: "jQuery" + (jQuery. fn. jquery + Math. random (). replace (/\ D/g ,""),....Data: function (elem, name, data, pvt/* Interna
(element, [key], [value]) does not overwrite any object bound to it. Is that true? Let's study their source code.First look at jQuery. data (element, [key], [value]) source code.
Js Code:
Copy codeThe Code is as follows:JQuery. extend ({Cache :{},// Please use with cautionUuid: 0,// Unique for each copy of jQuery on the page// Non-digits removed to match rinlinejQueryExpando: "jQuery" + (jQuery. fn. jquery + Math. random (). replace (/\ D/g ,""),....Data: function (elem, name, data, pvt/* Inter
Many users prefer to store data on the HTMLElement attribute in projects, such
View sourceprint? 1
2
Added the custom property "data" and value "some data" to the div on the page ". Use getAttribute in subsequent JS Code.
JQuery provides the data/removeData method from 1.2.3 to store/delete data. 1.6.1 code snippet
View sourceprint? 1 jQuery. extend ({
2 cache :{},
3
4 // Please use with caution
5 uuid: 0,
6
7...
8
9 });
That is, a static field/method is added to jQuery, including jQuery. cac
(element, [key], [value]) does not overwrite any object bound to it. Is that true? Let's study their source code.
First look at jQuery. data (element, [key], [value]) source code.Js Code:Copy codeThe Code is as follows: jQuery. extend ({Cache :{},// Please use with cautionUuid: 0,// Unique for each copy of jQuery on the page// Non-digits removed to match rinlinejQueryExpando: "jQuery" + (jQuery. fn. jquery + Math. random (). replace (/\ D/g ,""),....Data: function (elem, name, data, pvt/* Inter
Many users prefer to store data on the htmlelement attribute in projects, such
CopyCode The Code is as follows:
Added the custom property "data" and value "some data" to the DIV on the page ". Use getattribute in subsequent JS Code.Jquery provides the data/removedata method from 1.2.3 to store/delete data. 1.6.1 code snippetCopy codeThe Code is as follows: jquery. Extend ({Cache :{},// Please use with cautionUUID: 0,...});
That is, a static field/method is added to jquery, including jquery.
jquery 3.0 was officially released on June 9, and 3.0 is also known as the next generation of jquery. This version began in October 14 with a beta release (2016/1/14,) and a candidate version (2016/05/20). It's not easy to walk all the way.
First, data analysis
The Data in JQuery 3.0 is used internally and is defined as a "class". Altogether it created two objects, Datapriv and Datauser. Data has 1 object attributes (expando) and class attributes (U
may eject true. But here's how all browsers are unified:
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Is there a rigorous decision? Do not forget that window is an infinite loop referencing itself, it should be said to refer to the previous self. Therefore, we can:
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
The final conclusion:
Copy Code c
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.