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

ÈçºÎÕýÈ·µÄ¼ÓÔØjavascriptÎļþ

1£© Ϊʲô¼ÓÔØjavascriptÎļþºÜÖØÒª£¿
javascriptÎļþÊDZȽÏÌØÊâµÄ£¬ÒòΪä¯ÀÀÆ÷¼ÓÔØjavascriptÊÇ´®Ðеġ£ÒÔΪ×ÅÔÚ¼ÓÔØJavascriptÎļþµÄʱºò£¬ÆäËûÒ»ÇÐ×ÊÔ´µÄÏÂÔØ°üÀ¨Ò³ÃæµÄÏÔʾ¶¼»á±»×èÈû¡£
2£© ÈçºÎÕýÈ·µÄ¼ÓÔØJavaScript£¿
a. ½«JavaScriptÎļþ·ÅÔÚÒ³ÃæµÄ×îºó
ÒòΪJavaScriptµÄ¼ÓÔØ»á×èÈûÒ³ÃæµÄÏÔʾ£¬ËùÒÔ½«JavaScriptÎļþ·ÅÖÃÔÚÒ³ÃæµÄ×îºó£¬Ò²¾ÍÊÇ<body>±êÇ©½áÊøÇ°¡£ÕâÑùÓû§¿ÉÒÔ¸ü¿ìµÄ¿´µ½Ò³ÃæµÄÏÔʾ£¬¿ÉÒÔÓиüºÃµÄÓû§ÌåÑé¡£
b. ²¢ÐеļÓÔØJavaScript
Èç¹ûʹÓÃÆÕͨµÄ<script>±êÇ©À´ÒýÓÃÍⲿµÄJSÎļþ£¬ÄÇôJSÎļþµÄÏÂÔØÊÇ´®Ðеģ¬ÕâÑùͨ³£Ð§ÂÊ»á·Ç³£µÍ¡£ÍƼöʹÓÃLABjsÀ´¼ÓÔØJavaScript£¬¿ÉÒÔ´ïµ½JSÎļþµÄ²¢ÐÐÏÂÔØ£¬µ«Í¬Ê±ÓÖÓлúÖÆÀ´±£Ö¤JSÎļþÖ´ÐеÄ˳Ðò¡£
ÏÂÃæ¾ÍÊÇÒ»¸öʹÓÃLABjÀ´¼ÓÔØJavaScriptµÄÀý×Ó
<script>
   $LAB
   .script("framework.js").wait()
   .script("plugin.framework.js")
   .script("myplugin.framework.js")
   .wait(function(){
      myplugin.init();
      framework.init();
      framework.doSomething();
   });
</script>
¾ßÌå¿ÉÒԲ鿴LABjµÄ¹Ù·½ÍøÕ¾£ºhttp://labjs.com/
c. Lazy load
Õâ¸öÍùÍùÊǽ²ÆðÀ´±È½ÏÈÝÒ×£¬×öÆäËû±È½ÏÄÑ¡£Ô­ÀíºÜ¼òµ¥£¬¾ÍÊÇÒ³ÃæÏÔʾµÄʱºò£¬Ö»¼ÓÔØÐèÒªµÄJSÎļþ£¬È»ºóÔÚÓû§²Ù×÷µÄʱºòÔÙ¼ÓÔØÐèÒªµÄJSÎļþ¡£
d. ÕýÈ·µÄѹËõJSÎļþ
ʹÓÃJSMin»òÕßGoogle ClosureÀ´Ñ¹ËõJSÎļþ£¬Õâ¸öÍùÍù¿ÉÒÔ´ó´ó¼õÉÙJSÎļþµÄ´óС¡£
±¾ÎÄÀ´×ÔCSDN²©¿Í£¬×ªÔØÇë±êÃ÷³ö´¦£ºhttp://blog.csdn.net/Danwang/archive/2010/02/03/5286576.aspx


Ïà¹ØÎĵµ£º

javascript call

javaScript
ÖÐµÄ call
() ÊÇÒ»¸öÆæÃîµÄ·½·¨£¬µ«Ò²ÊÇÒ»¸öÈÃÈËÃÔ»óµÄ·½·¨£¬ÏÈ¿´Ò»Ï¹ٷ½µÄ½âÊÍ£º
call
·½·¨
Çë²ÎÔÄ
Ó¦ÓÃÓÚ£ºFunction ¶ÔÏó
񻂗
°æ±¾ 5.5
µ÷ÓÃÒ»¸ö¶ÔÏóµÄÒ»¸ö·½·¨£¬ÒÔÁíÒ»¸ö¶ÔÏóÌæ»»µ±Ç°¶ÔÏó¡£
call
([thisObj[,arg1[, arg2[,   [,.argN]]]]])
²ÎÊý
thisObj
¿ÉÑ¡Ïî¡£½«±»ÓÃ×÷µ±Ç ......

ÓÃJavaScriptÈ¥³ý×Ö·û´®µÄÊ×β¿Õ¸ñ¡£

String.prototype.Trim=function(){
returnthis.replace(/(^\s*)|(\s*$)/g,"");
}
String.prototype.LTrim=function(){
returnthis.replace(/(^\s*)/g,"");
}
String.prototype.RTrim=function(){
returnthis.replace(/(\s*$)/g,"");
} ......

ÓÃJavaScript»ñÈ¡QueryString£¨Î´²â£©

function QueryString(fieldName){
var urlString = location.search;
if (urlString != null) {
var typeQu = fieldName + "=";
var urlEnd = urlString.indexOf(typeQu);
if (urlEnd != -1) {
var paramsUrl = urlString.substring(urlEnd + typeQu.length);
var isEnd = paramsUrl.indexOf('&' ......

JavaScript·½·¨ºÍ¼¼ÇÉ´óÈ«

             JavaScript·½·¨ºÍ¼¼ÇÉ´óÈ«
1£º»ù´¡ÖªÊ¶
1 ´´½¨½Å±¾¿é
1: <script language=”JavaScript”>
2: JavaScript code goes here
3: </script>
2 Òþ²Ø½Å±¾´úÂë
1: <script language=”JavaScript”>
2: ......

ÀûÓÃJavaScriptʵÏÖÉÏ´«Í¼Æ¬Ô¤ÀÀ

<script >
function showimage()

       //IMG1ΪͼƬ¿Ø¼þ»òDiv,File1ΪÉÏ´«Îļþ¿Ø¼þ
document.getElementById("IMG1"). src = document.getElementById("File1").value;
}
</script >
¿Ø¼þÖÐÒýÓÃ:
<input id="File1" runat="server" type="file"  onc ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ