[·Òë]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 with an empty cache (http://yuiblog.com/blog/2007/01/04/performance-research-part-2/). In addition, another more recent study by the Yahoo! Search team, which was independently confirmed by Steve Souders of Google, indicates that roughly 15% of the content delivered by large websites in the United States is served uncompressed.
¸ù¾ÝYahoo!׿ԽÐÔÄÜÍŶÓÔÚ2007Äê½øÐеÄÑо¿£¬40%-60%µÄYahoo!Óû§Ã»ÓÐʹÓûº´æµÄ¾Ñ飬´óÔ¼20%Ò³ÃæÊÓͼ²»Ê¹Óûº´æ£¨http://yuiblog.com/blog/2007/01/04/performance-research-part-2/£©¡£ÁíÍ⣬ÓÉYahoo!Ñо¿Ð¡×é·¢ÏÖ£¬²¢ÓÉGoogleµÄSteve SoudersËù֤ʵµÄÒ»Ïî×îÐÂÑо¿±íÃ÷£¬´óÔ¼15%µÄÃÀ¹ú´óÐÍÍøÕ¾ËùÌṩµÄÄÚÈÝûÓÐѹËõ¡£
These facts emphasize the need to make sure that JavaScript-based web applications are delivered as efficiently as possible. While part of that work is done during the design and development cycles, the build and deployment phase is also essential and often overlooked. If care is not taken during this crucial phase, the performance of your application will suffer, no matter how much effort you've put into making it faster.
ÕâЩÊÂʵǿµ÷ÓбØҪȷ±£ÄÇЩ»ùÓÚJavaScriptµÄÍøÒ³Ó¦Óþ¡Á¿¸ßЧµØ·¢²¼¡£ËäÈ»²¿·Ö¹¤×÷ÔÚÉè¼Æ¿ª·¢¹ý³ÌÖÐÒѾÍê³É£¬µ«¹¹½¨ºÍ²¿Êð¹ý³ÌÒ²ºÜÖØÒªÇÒÍùÍù±»ºöÊÓ¡£Èç¹ûÔÚÕâ¸ö¹Ø¼ü¹ý³ÌÖв»¹»Ð¡ÐÄ£¬ÄãÓ¦ÓóÌÐòµÄÐÔÄܽ«Êܵ½Ó°Ï죬ÎÞÂÛÄãÔõÑùŬÁ¦Ê¹Ëü¸ü¿ì¡£
The purpose of this chapter is to give you the necessary knowledge to efficiently assemble and deploy a JavaScript-based web application. A number of concepts are illustrated using Apache Ant, a Java-based build tool that has quickly become an industry standard for building applications for the Web. Toward the end of the chapter, a custo
Ïà¹ØÎĵµ£º
ʹÓÃ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( ......
Splitting Up Tasks ·Ö½âÈÎÎñ
What we typically think of as one task can often be broken down into a series of subtasks. If a single function is taking too long to execute, check to see whether it can be broken down into a series of smaller functions that complete in smaller ......
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:
×ܵÄÀ´ËµÔ½ÇáÁ¿¼¶µÄ¸ñʽԽºÃ£¬× ......
Use the Fast Parts ʹÓÃËٶȿìµÄ²¿·Ö
Even though JavaScript is often blamed for being slow, there are parts of the language that are incredibly fast. This should come as no surprise, since JavaScript engines are built in lower-level languages and are therefore compiled. Thou ......