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

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

JavaScript Minification  JavaScript½ô´Õ
    JavaScript minification is the process by which a JavaScript file is stripped of everything that does not contribute to its execution. This includes comments and unnecessary whitespace. The process typically reduces the file size by half, resulting in faster downloads, and encourages programmers to write better, more extensive inline documentation.
    JavaScript½ô´ÕÖ¸µÄÊÇÌÞ³ýÒ»¸öJavaScriptÎļþÖÐÒ»ÇÐÔËÐÐÎÞ¹ØÄÚÈݵĹý³Ì¡£°üÀ¨×¢ÊͺͲ»±ØÒªµÄ¿Õ¸ñ¡£¸Ã´¦Àíͨ³£¿É½«Îļþ³ß´çËõ¼õµ½Ò»°ë£¬Æä½á¹ûÊÇÏÂÔØËٶȸü¿ì£¬²¢¹ÄÀø³ÌÐòԱд³ö¸üºÃ£¬¸üÏêϸµÄÄÚÁªÎĵµ¡£
    JSMin (http://www.crockford.com/javascript/jsmin.html), developed by Douglas Crockford, remained the standard in JavaScript minification for a long time. However, as web applications kept growing in size and complexity, many felt it was time to push JavaScript minification a step further. This is the main reason behind the development of the YUI Compressor (http://developer.yahoo.com/yui/compressor/), a tool that performs all kinds of smart operations in order to offer a higher level of compaction than other tools in a completely safe way. In addition to stripping comments and unnecessary whitespace, the YUI Compressor offers the following features:
    JSMin£¨http://www.crockford.com/javascript/jsmin.html£©£¬ÓÉDouglas Crockford¿ª·¢£¬Ëü±£³ÖÁËJavaScript½ô´Õ±ê×¼ºÜ³¤Ò»¶Îʱ¼ä¡£È»¶øËæ×ÅÍøÂçÓ¦ÓóÌÐòÔÚ¹æÄ£ºÍ¸´ÔÓÐÔÉϲ»¶ÏÔö³¤£¬Ðí¶àÈËÈÏΪJavaScript½ô´ÕÓ¦µ±ÔÙÏòÇ°ÍƽøÒ»²½¡£ÕâÊÇ¿ª·¢YUIѹËõÆ÷µÄÖ÷ÒªÔ­Òò£¨http://developer.yahoo.com/yui/compressor/£©ËüÌṩÁËËùÓÐÀàÐ͵ÄÖÇÄܲÙ×÷£¬ÎªÁËÌṩ±ÈÆäËü¹¤¾ß¸ü¸ß¼¶µÄ½ô´Õ²Ù×÷²¢ÇÒÒÔÍêÈ«°²È«µÄ·½·¨ÊµÏÖ¡£³ýÁËÌÞ³ý×¢ÊͺͲ»±ØÒªµÄ¿Õ¸ñ£¬YUIѹËõÆ÷»¹ÌṩÒÔϹ¦ÄÜ£º
• Replacement of local variable names with shorter (one-, two-, or three-character) variable names, picked to optimize gzip compression downstream
  ½«¾Ö²¿±äÁ¿ÃûÌæ»»ÒÔ¸ü¶ÌµÄÐÎʽ£¨1¸ö£¬2¸ö£¬»ò3¸ö×Ö·û£©£¬ÒÔÓÅ»¯ºóÐøµÄgzipѹËõ¹¤×÷
• Rep


Ïà¹ØÎĵµ£º

Javascript¼ì²éÈÕÆÚ¸ñʽÊÇ·ñºÏ·¨µÄÒ»ÖÖ¼ò»¯·½·¨¡£

³£¹æµÄ·½·¨Êǽ«ÄêÔÂÈÕÈ¡³ö£¬È»ºó·Ö±ðÅжϷ¶Î§£¬È»ºó¾ÍÅжÏÈòÄê2ÔµÄÌìÊý
¿ÉÒÔͨ¹ýnew Date(string)µÄ¹¹Ô죬±È½ÏÄêÔÂÈÕ×Ö·ûÊÇ·ñ·¢Éú±ä»¯Åжϡ£
function CheckDate(text) {
if (!text) return false;
text = text.replace(/[\/-]0?/g, "/");
if (!text.match(/^\d{4}\/\d{1,2}\/\d{1,2}$/)) return true; ......

[·­Òë]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.
......

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

Data Format Conclusions  Êý¾Ý¸ñʽ×ܽá
    Favor lightweight formats in general; the best are JSON and a character-delimited custom format. If the data set is large and parse time becomes an issue, use one of these two techniques:
    ×ܵÄÀ´ËµÔ½ÇáÁ¿¼¶µÄ¸ñʽԽºÃ£¬× ......

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

µÚ¾ÅÕÂ
Building and Deploying High-Performance JavaScript Applications
´´½¨²¢²¿Êð¸ßÐÔÄÜJavaScriptÓ¦ÓóÌÐò
    According to a 2007 study by Yahoo!'s Exceptional Performance team, 40%–60% of Yahoo!'s users have an empty cache experience, and about 20% of all page views are done ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ