Saturday, January 12, 2008 1:28 AM
TanzimSaqib
ASP.NET AJAX Best Practices: Introduce DOM elements and function caching
We have seen DOM caching before and function delegation is also a kind of function caching. Take a look at the following snippet:
for(var i=0; i<count; ++i)
$get('divContent').appendChild(elements
); As you can figure out the code is going to be something like:
var divContent = $get('divContent');
for(var i=0; i<count; ++i)
divContent.appendChild(elements
); That is fine, but you can also cache browser function like
appendChild. So, the ultimate optimization will be like the following:
var divContentAppendChild = $get('divContent').appendChild;
for(var i=0; i<count; ++i)
divContentAppendChild(elements
);
Filed Under:
JavaScript,
AJAX,
Performance
Anonymous comments are disabled
About TanzimSaqib
Tanzim Saqib is a
Senior Developer, who spent half of his life on software and worked for many companies like #1 .NET controls provider
Telerik Inc, #1 personalized Web 2.0 start-page like
Pageflakes (acquired by LiveUniverse). He developed many projects ranging from banking solutions for Citibank, HSBC, Wamu, Wells Fargo etc. to
Paperless Virtual University. He is industry's earliest and leading widget developer and as know as
"Widget Master" to his peers.
He is a preacher of Microsoft technologies. While he jams with the latest additions to .NET, in his spare time he blogs at
http://weblogs.asp.net/TanzimSaqib, maintains his personal website
http://www.TanzimSaqib.com, leads
.NET Research group. writes articles.
He is an
easy going, fun loving, and
passionate technology individual who is open to any kind of
business opportunity and professional relationship. He currently lives in Bangladesh, but travels anywhere in the world on professional demand.
Email: me at TanzimSaqib dot com