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

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

Data Formats  Êý¾Ý¸ñʽ
    When considering data transmission techniques, you must take into account several factors: feature set, compatibility, performance, and direction (to or from the server). When considering data formats, the only scale you need for comparison is speed.
    ÔÚ¿¼ÂÇÊý¾Ý´«Êä¼¼Êõʱ£¬Äã±ØÐ뿼ÂÇÕâЩÒòËØ£º¹¦Äܼ¯£¬¼æÈÝÐÔ£¬ÐÔÄÜ£¬ºÍ·½Ïò£¨·¢¸ø·þÎñÆ÷»òÕß´Ó·þÎñÆ÷½ÓÊÕ£©¡£ÔÚ¿¼ÂÇÊý¾Ý¸ñʽʱ£¬Î¨Ò»ÐèÒª±È½ÏµÄ³ß¶ÈµÄ¾ÍÊÇËÙ¶È¡£
    There isn't one data format that will always be better than the others. Depending on what data is being transferred and its intended use on the page, one might be faster to download, while another might be faster to parse. In this section, we create a widget for searching among users and implement it using each of the four major categories of data formats. This will require us to format a list of users on the server, pass it back to the browser, parse that list into a native JavaScript data structure, and search it for a given string. Each of the data formats will be compared based on the file size of the list, the speed of parsing it, and the ease with which it's formed on the server.
    ûÓÐÄÄÖÖÊý¾Ý¸ñʽ»áʼÖÕ±ÈÆäËû¸ñʽ¸üºÃ¡£¸ù¾Ý´«ËÍʲôÊý¾Ý¡¢ÓÃÓÚÒ³ÃæÉÏʲôĿµÄ£¬Ä³ÖÖ¸ñʽ¿ÉÄÜÏÂÔØ¸ü¿ì£¬ÁíÒ»ÖÖ¸ñʽ¿ÉÄܽâÎö¸ü¿ì¡£ÔÚ±¾½ÚÖУ¬ÎÒÃÇ´´½¨ÁËÒ»¸ö´°¿ÚС²¿¼þÓÃÓÚËÑË÷Óû§ÐÅÏ¢²¢ÓÃËÄÖÖÖ÷Á÷µÄÊý¾Ý¸ñʽʵÏÖËü¡£ÕâÒªÇóÎÒÃÇÔÚ·þÎñÆ÷¶Ë¸ñʽ»¯Ò»¸öÓû§ÁÐ±í£¬½«Ëü·µ»Ø¸øä¯ÀÀÆ÷£¬½«Áбí½âÎö³ÉJavaScriptÊý¾Ý¸ñʽ£¬²¢ËÑË÷ÌØ¶¨µÄ×Ö·û´®¡£Ã¿ÖÖÊý¾Ý¸ñʽ½«±È½ÏÁбíµÄÎļþ´óС£¬½âÎöËÙ¶È£¬ºÍ·þÎñÆ÷ÉϹ¹ÔìËüÃǵÄÄÑÒ׳̶ȡ£
XML
    When Ajax first became popular, XML was the data format of choice. It had many things going for it: extreme interoperability (with excellent support on both the server side and the client side), strict formatting, and easy validation. JSON hadn't been formalized yet as an interchange format, and almost every language used on servers had a library available for working with XML.
&


Ïà¹ØÎĵµ£º

javaScript¹Ø±Õä¯ÀÀÆ÷ (²»µ¯³öÌáʾ¿ò)

£¼script language="javaScript"£¾
function closeWindow()
{
¡¡window.opener = null;
¡¡window.open(' ', '_self', ' ');
¡¡window.close();
}
£¼/script£¾
£¼input type='button' value='¹Ø±Õ´°¿Ú' onClick="closeWindow()"£¾
»ò
£¼input type="button" value="¹ ......

Javascript±Õ°ü(Closure)

ClosureÖÐÎÄ·­ÒëΪ±Õ°ü.×ÖÃæÉÏÀ´Àí½â¾ÍÊÇ"·â±ÕµÄ°ü".(ÕâÊÇÒ»¾ä·Ï»°)
±Õ°üÊÇʲô?
ÊéÃæ½âÊÍΪ:
Ëùν“±Õ°ü”£¬Ö¸µÄÊÇÒ»¸öÓµÓÐÐí¶à±äÁ¿ºÍ°ó¶¨ÁËÕâЩ±äÁ¿µÄ»·¾³µÄ±í´ïʽ£¨Í¨³£ÊÇÒ»¸öº¯Êý£©£¬Òò¶øÕâЩ±äÁ¿Ò²ÊǸñí´ïʽµÄÒ»²¿·Ö¡£
ÎÒÈÏΪ±Õ°ü¾ÍÊÇÄܹ»¶Á/дº¯ÊýÄÚ²¿µÄijЩ±äÁ¿µÄ×Óº¯Êý,²¢½«ÕâЩ±äÁ¿±£´æ ......

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

Recursion Patterns  µÝ¹éģʽ
    When you run into a call stack size limit, your first step should be to identify any instances of recursion in the code. To that end, there are two recursive patterns to be aware of. The first is the straightforward recursive pattern represented ......

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

Regular Expression Optimization  ÕýÔò±í´ïʽÓÅ»¯
    Incautiously crafted regexes can be a major performance bottleneck (the upcoming section, "Runaway Backtracking" on page 91, contains several examples showing how severe this can be), but there is a lot you can do to improve re ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ