[·Òë]High Performance JavaScript(002)
Grouping Scripts ³É×é½Å±¾
Since each <script> tag blocks the page from rendering during initial download, it's helpful to limit the total number of <script> tags contained in the page. This applies to both inline scripts as well as those in external files. Every time a <script> tag is encountered during the parsing of an HTML page, there is going to be a delay while the code is executed; minimizing these delays improves the overall performance of the page.
ÓÉÓÚÿ¸ö<script>±êÇ©ÏÂÔØʱ×èÈûÒ³Ãæ½âÎö¹ý³Ì£¬ËùÒÔÏÞÖÆÒ³ÃæµÄ<script>×ÜÊýÒ²¿ÉÒÔ¸ÄÉÆÐÔÄÜ¡£Õâ¸ö¹æÔò¶ÔÄÚÁª½Å±¾ºÍÍⲿ½Å±¾Í¬ÑùÊÊÓá£Ã¿µ±Ò³Ãæ½âÎöÅöµ½Ò»¸ö<script>±êǩʱ£¬½ô½Ó×ÅÓÐÒ»¶Îʱ¼äÓÃÓÚ´úÂëÖ´ÐС£×îС»¯ÕâЩÑÓ³Ùʱ¼ä¿ÉÒÔ¸ÄÉÆÒ³ÃæµÄÕûÌåÐÔÄÜ¡£
The problem is slightly different when dealing with external JavaScript files. Each HTTP request brings with it additional performance overhead, so downloading one single 100 KB file will be faster than downloading four 25 KB files. To that end, it's helpful to limit the number of external script files that your page references. Typically, a large website or web application will have several required JavaScript files. You can minimize the performance impact by concatenating these files together into a single file and then calling that single file with a single <script> tag. The concatenation can happen offline using a build tool (discussed in Chapter 9) or in real-time using a tool such as the Yahoo! combo handler.
Õâ¸öÎÊÌâÓëÍⲿJavaScriptÎļþ´¦Àí¹ý³ÌÂÔÓв»Í¬¡£Ã¿¸öHTTPÇëÇ󶼻á²úÉú¶îÍâµÄÐÔÄܸºµ££¬ÏÂÔØÒ»¸ö100KBµÄÎļþ±ÈÏÂÔØËĸö25KBµÄÎļþÒª¿ì¡£×ÜÖ®£¬¼õÉÙÒýÓÃÍⲿ½Å±¾ÎļþµÄÊýÁ¿¡£µäÐ͵ģ¬Ò»¸ö´óÐÍÍøÕ¾»òÍøÒ³Ó¦ÓÃÐèÒª¶à´ÎÇëÇóJavaScriptÎļþ¡£Äã¿ÉÒÔ½«ÕâЩÎļþÕûºÏ³ÉÒ»¸öÎļþ£¬Ö»ÐèÒªÒ»¸ö<script>±êÇ©ÒýÓ㬾ͿÉÒÔ¼õÉÙÐÔÄÜËðʧ¡£ÕâһϵÁеŤ×÷¿Éͨ¹ýÒ»¸ö´ò°ü¹¤¾ßʵÏÖ£¨ÎÒÃÇÔÚµÚ9ÕÂÌÖÂÛ£©£¬»òÕßÒ»¸öʵʱ¹¤¾ß£¬ÖîÈç“Yahoo! combo handler”¡£
Yahoo! created the
Ïà¹ØÎĵµ£º
ÉÏÃæËù˵ÓйØHTMLµÄÄÚÈݷdz£ÉÙÓÖ¼òµ¥,µ«¶ÔÒѾÁ˽âµÄÈËÀ´Ëµ¾ÍÊÇûÓõÄ.
ÈçÓÐÎÊÌâ¿Éµ½È¨ÍþÍø http://www.html.com/ Éϲ鿴
ÒÔÏ¿ªÊ¼ËµËµ¹ØÓÚXMLµÄһЩ֪ʶ.
XMLÒ²ÊDZê¼ÇÓïÑÔ,¿ÉËüÊÇ×Ô¶¨ÒåµÄ,ûÓÐÒѸø¶¨¸ñʽ.²»¾ßÌå˵Ëü,¸ø³öÀý×ӾͿÉÃ÷ÁË.
Èç
<NAME>TOM</NAME>
<SEX>M</SEX>
ÒÔÉÏÄÚÈݵÄ< ......
/**
* JavaScript ÊÇÃæÏò¶ÔÏóµÄÓïÑÔ£¬µ«ÊÇËûµÄÃæÏò¶ÔÏó²»ÊÇ»ùÓÚÀàµÄ£¬ÊÇ»ùÓÚÔÐ͵Ä;
* µ«ÊÇËûµÄһЩÌØÐÔ(º¯ÊýÊÇÊý¾Ý)£¬Ê¹µÃËü¿ÉÒÔÄ£Äâ»ùÓÚÀàµÄÃæÏò¶ÔÏ󣬵«ÊÇ JavaScript ²¢²»Ö§³ÖºÍ Java Ò»ÑùµÄÀ࣬
* Òò´Ë JavaScript ÖеÄ"Àà"¿ÉÒÔ³Æ×÷"αÀà"
*/
//
/**
* ¹¹Ô캯Êý: js ÖÐÓÃÀ´ºÍ new ÔËËã·ûÒ»ÆðʹÓõĺ¯Êý³Æ× ......
1. ¶¨ÒåÒ»¸öÓÃÓÚÊä³öJavaScript´úÂë µÄServletÀà¡£
package com.mycompany.response.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServle ......
C#´úÂëÓëjavaScriptº¯ÊýµÄÏ໥µ÷ÓÃ
ÎÊ£º
1.ÈçºÎÔÚJavaScript·ÃÎÊC#º¯Êý?
2.ÈçºÎÔÚJavaScript·ÃÎÊC#±äÁ¿?
3.ÈçºÎÔÚC#ÖзÃÎÊJavaScriptµÄÒÑÓбäÁ¿?
4.ÈçºÎÔÚC#ÖзÃÎÊJavaScriptº¯Êý?
ÎÊÌâ1´ð°¸ÈçÏ£º
javaScriptº¯ÊýÖÐÖ´ÐÐC#´úÂëÖеĺ¯Êý£º
·½·¨Ò»£º1¡¢Ê×ÏȽ¨Á¢Ò»¸ö°´Å¥£¬ÔÚºǫ́½«µ÷Óûò´¦ÀíµÄÄÚÈÝдÈëbutton_clickÖÐ ......
ÀàÊÇʲô£¿
Ðí¶à¸Õ½Ó´¥±à³ÌµÄÅóÓѶ¼¿ÉÄÜÀí½â²»ÁËÀ࣬ÆäʵÀàÊǶÔÎÒÃÇÕâ¸öÏÖʵÊÀ½çµÄÄ£Ä⣬°ÑËü˵³É“Àà±ð”»òÕß“ÀàÐÍ”¿ÉÄÜ»á¸üÈÝÒ×Àí½âһЩ¡£±ÈÈç“ÈË”ÕâÖÖ¶¯
Îï¾ÍÊÇÒ»¸öÀ࣬¶ø¾ßÌåijһ¸öÈ˾ÍÊÇ“ÈË”Õâ¸öÀàµÄÒ»¸öʵÀý
£¬
“È ......