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

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

µÚÁùÕ  Responsive Interfaces  ÏìÓ¦½Ó¿Ú
    There's nothing more frustrating than clicking something on a web page and having nothing happen. This problem goes back to the origin of transactional web applications and resulted in the now-ubiquitous "please click only once" message that accompanies most form submissions. A user's natural inclination is to repeat any action that doesn't result in an obvious change, and so ensuring responsiveness in web applications is an important performance concern.
    ûÓÐʲô±Èµã»÷Ò³ÃæÉϵĶ«Î÷ȴʲôҲû·¢Éú¸üÁîÈ˸е½´ìÕÛÁË¡£Õâ¸öÎÊÌâÓֻص½ÁËÔ­Ê¼ÍøÒ³½»»¥³ÌÐòºÍÏÖÔÚÒÑÎÞ´¦²»ÔÚµÄÌá½»±íµ¥Ê±µ¯³öµÄ“ÇëÎðÖØ¸´Ìá½»”ÏûÏ¢ÉÏÃæ¡£Óû§×ÔÈ»ÇãÏòÓÚÖØ¸´³¢ÊÔÕâЩ²»·¢ÉúÃ÷ÏԱ仯µÄ¶¯×÷£¬ËùÒÔÈ·±£ÍøÒ³Ó¦ÓóÌÐòµÄÏìÓ¦ËÙ¶ÈÒ²ÊÇÒ»¸öÖØÒªµÄÐÔÄܹØ×¢µã¡£
    Chapter 1 introduced the browser UI thread concept. As a recap, most browsers have a single process that is shared between JavaScript execution and user interface updates. Only one of these operations can be performed at a time, meaning that the user interface cannot respond to input while JavaScript code is executed and vice versa. The user interface effectively becomes "locked" when JavaScript is executing; managing how long your JavaScript takes to execute is important to the perceived performance of a web application.
    µÚÒ»½Ú½éÉÜÁËä¯ÀÀÆ÷UIÏ̸߳ÅÄî¡£×ܵÄÀ´Ëµ£¬´ó¶àÊýä¯ÀÀÆ÷ÓÐÒ»¸öµ¥¶ÀµÄ´¦Àí½ø³Ì£¬ËüÓÉÁ½¸öÈÎÎñËù¹²Ïí£ºJavaScriptÈÎÎñºÍÓû§½çÃæ¸üÐÂÈÎÎñ¡£Ã¿¸öʱ¿ÌÖ»ÓÐÆäÖеÄÒ»¸ö²Ù×÷µÃÒÔÖ´ÐУ¬Ò²¾ÍÊÇ˵µ±JavaScript´úÂëÔËÐÐʱÓû§½çÃæ²»ÄܶÔÊäÈë²úÉú·´Ó¦£¬·´Ö®ÒàÈ»¡£»òÕß˵£¬µ±JavaScriptÔËÐÐʱ£¬Óû§½çÃæ¾Í±»“Ëø¶¨”ÁË¡£¹ÜÀíºÃJavaScriptÔËÐÐʱ¼ä¶ÔÍøÒ³Ó¦ÓõÄÐÔÄܺÜÖØÒª¡£
The Browser UI Thread  ä¯ÀÀÆ÷UIÏß³Ì
    The process shared by JavaScript and user interface updates is frequently referred to as the browser UI thread (though the term "thread" is not necessarily accurate for all browsers). The UI thread works on a sim


Ïà¹ØÎĵµ£º

ͨ¹ýjavascript»ñµÃurl²ÎÊý

Ò³ÃæÌá½»Êý¾ÝÒ»°ãÓÐÁ½ÖÖ·½·¨£ºget,post¡£post¾ÍÊÇËùνµÄformÌá½»£¬Ê¹ÓÃÊÓͼ£»getÊÇͨ¹ýurlÌá½»¡£
Get·½·¨Ò»°ãÓúǫ́´úÂ루Èçasp,asp.net£©»ñµÃ²ÎÊý£¬´úÂëºÜ¼òµ¥£ºRequest.QueryString["id"];¼´¿É»ñÈ¡¡£ 
ÓÐЩʱºòÐèÒªÖ±½ÓÔÚǰ̨»ñÈ¡url²ÎÊý£¬ÒªÓõ½javascript£¬jsûÓÐÖ±½Ó»ñÈ¡url²ÎÊýµÄ·½·¨£¬ÄÇô£¬ÎÒÃÇÈçºÎͨ¹ýjs ......

javascript¼Ì³Ð·½Ê½Ö®¶þ

2¡¢Ô­ÐÍ·½Ê½Ð´À࣬ԭÐÍ·½Ê½¼Ì³Ð
core js×ÔÉíµÄ¶ÔÏóϵͳ¾ÍÊDzÉÓÃÔ­ÐÍ·½Ê½(prototype based)¼Ì³ÐµÄ¡£»òÕß˵core
jsûÓвÉÓó£¼ûµÄÀà¼Ì³Ð(class
based)ϵͳ£¬¶øÊÇʹÓÃÔ­Ðͼ̳ÐÀ´ÊµÏÖ×Ô¼ºµÄ¶ÔÏóϵͳ¡£¹¤×÷ÖÐÎÒÃÇÒ²¿ÉÒÔÓÃÔ­ÐÍ·½Ê½À´ÊµÏּ̳У¬´úÂ븴ÓÃÒÔ¹¹½¨×Ô¼ºµÄ¹¦ÄÜÄ£¿é¡£
/**
* ¸¸ÀàPolygon:¶à±ßÐÎ
*
*/
functio ......

JavaScript»ù´¡ÖªÊ¶1

JavascriptÊý¾ÝÀàÐÍ
ÓÉÓÚjavascriptÊÇÈõÀàÐÍÓïÑÔ£¬¼´¶¨Òå±äÁ¿Ê±²»±ØÉùÃ÷ÆäÀàÐÍ
¡£µ«Õâ²¢²»Òâζ×űäÁ¿Ã»ÓÐÀàÐÍ¡£ÒòΪ¸³ÖµÊ±»á×Ô¶¯Æ¥ÅäÊý¾ÝÀàÐÍ£¡
ĿǰÓõ½µÄ»ù±¾Êý¾ÝÀàÐÍ
number
boolean
string
var i
i="test";//Õâʱi¾Í³ÉÁËstringÀàÐÍ
var i
i=4;//Õâʱi¾Í³ÉÁËnumberÀàÐÍ
³£ÓöÔÏóÀàÐÍ<object> ......

javascript typeofÓ¦ÓÃ

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

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

µÚËÄÕ  Algorithms and Flow Control  Ëã·¨ºÍÁ÷³Ì¿ØÖÆ
    The overall structure of your code is one of the main determinants as to how fast it will execute. Having a very small amount of code doesn't necessarily mean that it will run quickly, and having a large amount of code ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ