Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

[·­Òë]High Performance JavaScript(022)

µÚÆßÕ  Ajax  Òì²½JavaScriptºÍXML
    Ajax is a cornerstone of high-performance JavaScript. It can be used to make a page load faster by delaying the download of large resources. It can prevent page loads altogether by allowing for data to be transferred between the client and the server asynchronously. It can even be used to fetch all of a page's resources in one HTTP request. By choosing the correct transmission technique and the most efficient data format, you can significantly improve how your users interact with your site.
    AjaxÊǸßÐÔÄÜJavaScriptµÄ»ùʯ¡£Ëü¿ÉÒÔͨ¹ýÑÓ³ÙÏÂÔØ´óÁ¿×ÊÔ´Ê¹Ò³Ãæ¼ÓÔØ¸ü¿ì¡£Ëüͨ¹ýÔÚ¿Í»§¶ËºÍ·þÎñÆ÷Ö®¼äÒì²½´«ËÍÊý¾Ý£¬±ÜÃâÒ³Ãæ¼¯Ìå¼ÓÔØ¡£Ëü»¹ÓÃÓÚÔÚÒ»´ÎHTTPÇëÇóÖлñÈ¡Õû¸öÒ³ÃæµÄ×ÊÔ´¡£Í¨¹ýÑ¡ÔñÕýÈ·µÄ´«Êä¼¼ÊõºÍ×îÓÐЧµÄÊý¾Ý¸ñʽ£¬Äã¿ÉÒÔÏÔÖø¸ÄÉÆÓû§ÓëÍøÕ¾Ö®¼äµÄ»¥¶¯¡£
    This chapter examines the fastest techniques for sending data to and receiving it from the server, as well as the most efficient formats for encoding data.
    ±¾Õ¿¼²ì´Ó·þÎñÆ÷ÊÕ·¢Êý¾Ý×î¿ìµÄ¼¼Êõ£¬ÒÔ¼°×îÓÐЧµÄÊý¾Ý±àÂë¸ñʽ¡£
Data Transmission  Êý¾Ý´«Êä
    Ajax, at its most basic level, is a way of communicating with a server without unloading the current page; data can be requested from the server or sent to it. There are several different ways of setting up this communication channel, each with its own advantages and restrictions. This section briefly examines the different approaches and discusses the performance implications of each.
    Ajax£¬ÔÚËü×î»ù±¾µÄ²ãÃæ£¬ÊÇÒ»ÖÖÓë·þÎñÆ÷ͨѶ¶ø²»ÖØÔص±Ç°Ò³ÃæµÄ·½·¨£¬Êý¾Ý¿É´Ó·þÎñÆ÷»ñµÃ»ò·¢Ë͸ø·þÎñÆ÷¡£ÓжàÖÖ²»Í¬µÄ·½·¨¹¹ÔìÕâÖÖͨѶͨµÀ£¬Ã¿ÖÖ·½·¨¶¼ÓÐ×Ô¼ºµÄÓÅÊÆºÍÏÞÖÆ¡£±¾½Ú¼òÒªµØ½éÉÜÕâЩ²»Í¬·½·¨£¬²¢ÌÖÂÛ¸÷×Ô¶ÔÐÔÄܵÄÓ°Ïì¡£
Requesting Data  ÇëÇóÊý¾Ý
    There are five general techniques for requesting data from a server:
    ÓÐÎåÖÖ³£Óü¼ÊõÓÃÓÚÏò·þÎñÆ÷ÇëÇóÊý¾Ý£º
• XMLHttpRequest (XHR)
• Dynamic scrip


Ïà¹ØÎĵµ£º

[ת]¾«Í¨JSON (JavaScript Object Notation)


[ת×Ô]http://article.yeeyan.org/view/mouse4x/16540
JSON±»¹«ÈÏΪä¯ÀÀÆ÷ÖÐXMLµÄºó¼ÌÕߣ¬ËüµÄÄ¿±ê½ö½öÊdzÉΪһÖÖ¼òµ¥¡¢ÓÅÑŵÄÊý¾Ý¸ñʽ£¬ÒÔ·½±ãä¯ÀÀÆ÷ºÍ·þÎñÆ÷Ö®¼äµÄÊý¾Ý½»»»¡£ÔÚÍê³ÉÕâÒ»¼òµ¥ÈÎÎñµÄ¹ý³ÌÖУ¬Ëü½«ÒýÁìÏÂÒ»´úÍòÎ¬Íø¡£
¶ÔÏó¼ò½é
¿´,Õâ¾ÍÊÇÒ»¸ö¶ÔÏó:
var myFirstObject ={};
¾¡¹Ü¿´ÆðÀ´Í¦¼òµ¥£¬È»¶øÄÇЩ» ......

javascript typeofÓ¦ÓÃ

typeof ÊÇJavaScriptµÄÔËËã·û
    ——·µ»ØÒ»¸öÓÃÀ´±íʾ±í´ïʽµÄÊý¾ÝÀàÐ͵Ä×Ö·û´®
   typeof[(] expression [)]  //typeofÓï·¨ÖеÄÔ²À¨ºÅÊÇ¿ÉÑ¡Ïî
  typeof ÔËËã·û@import url(../html-vss/msdnie4a.css);
typeof
ÔËËã·û°ÑÀàÐÍÐÅÏ¢µ±×÷×Ö·û´®·µ»Ø¡£typeof
·µ»ØÖµÓÐÁ ......

javascript¶¯Ì¬×°ÈëXMLÊý¾Ý


ʹÓÃjavascript´´½¨Microsoft XML DOM,¾Í¿ÉÒÔÍê³ÉÕâÒ»¹¤×÷.
// ×°ÈëÊý¾Ý.
var source = new ActiveXObject("Microsoft.XMLDOM");
source.async = false
source.load("history.xml");
// ×°ÈëÑùʽ±í.
var stylesheet = new ActiveXObject("Microsoft.XMLDOM");
stylesheet.async = false
stylesheet.load( ......

javascriptʵÏÖ×Ô¶¯ÇóºÍ

function total(){
var i=0;
for(j=1;j<=20;j++)
{
var step="step"+j;
if(document.getElementById(step)){
if(document.getElementById(step).checked==true)
{
i=i+parseInt(document.getElementById(step).value);
}
}
}
document.getElementById("total").innerHTML = i;
}
function Resetvalue(){
......

[·­Òë]High Performance JavaScript(017)

A Note on Benchmarking  ²âÊÔ»ù׼˵Ã÷
    Because a regex's performance can be wildly different depending on the text it's applied to, there's no straightforward way to benchmark regexes against each other. For the best result, you need to benchmark your regexes on test strings o ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ