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

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

Cloning Nodes  ½Úµã¿Ë¡
    Another way of updating page contents using DOM methods is to clone existing DOM elements instead of creating new ones—in other words, using element.cloneNode() (where element is an existing node) instead of document.createElement().
    ʹÓÃDOM·½·¨¸üÐÂÒ³ÃæÄÚÈݵÄÁíÒ»¸ö;¾¶ÊǿˡÒÑÓÐDOMÔªËØ£¬¶ø²»ÊÇ´´½¨Ðµė—¼´Ê¹ÓÃelement.cloneNode()£¨elementÊÇÒ»¸öÒÑ´æÔڵĽڵ㣩´úÌædocument.createElement();
    Cloning nodes is more efficient in most browsers, but not by a big margin. Regenerating the table from the previous example by creating the repeating elements only once and then copying them results in slightly faster execution times:
    ÔÚ´ó¶àÊýä¯ÀÀÆ÷ÉÏ£¬¿Ë¡½Úµã¸üÓÐЧÂÊ£¬µ«Ìá¸ß²»Ì«¶à¡£ÓÿË¡½ÚµãµÄ°ì·¨ÖØÐÂÉú³ÉÇ°ÃæÀý×ÓÖÐµÄ±í£¬µ¥ÔªÖ»´´½¨Ò»´Î£¬È»ºóÖØ¸´Ö´Ðи´ÖƲÙ×÷£¬ÕâÑù×öÖ»ÊÇÉÔ΢¿ìÁËÒ»µã£º
• 2% in IE8, but no change in IE6 and IE7
 ÔÚIE8Öпì2%£¬µ«ÔÚIE6ºÍIE7ÖÐÎޱ仯
• Up to 5.5% in Firefox 3.5 and Safari 4
 ÔÚFirefox 3.5ºÍSafari 4ÖпìÁË5.5%
• 6% in Opera (but no savings in Opera 10)
 ÔÚOperaÖпìÁË6%£¨µ«ÊÇÔÚOpera 10ÖÐÎޱ仯£©
• 10% in Chrome 2 and 3% in Chrome 3
ÔÚChrome 2ÖпìÁË10%£¬ÔÚChrome 3ÖпìÁË3%
    As an illustration, here's a partial code listing for generating the table using element.cloneNode():
    Ò»¸öʾÀý£¬ÕâÀïÊÇʹÓÃelement.cloneNode()´´½¨±íµÄ²¿·Ö´úÂ룺
function tableClonedDOM() {
  var i, table, thead, tbody, tr, th, td, a, ul, li,
  oth = document.createElement('th'),
  otd = document.createElement('td'),
  otr = document.createElement('tr'),
  oa = document.createElement('a'),
  oli = document.createElement('li'),
  oul = document.createElement('ul');
  tbody = document.createElement('tbody');
  for (i = 1; i <= 1000; i++) {
    tr = otr.cloneNode(false);
    td = otd.cloneNode(false);
&nb


Ïà¹ØÎĵµ£º

javascriptЧÂʾ­Ñé̸(Ò»)

±¾ÎÄÖ÷ÒªÊdzöÓÚÓÐÅóÓÑʹÓÃÎÒÔ­À´Ð´µÄautocompleteµÄJS¿Ø¼þ¡£µ±Êý¾ÝÁ¿´óµÄʱºò£¬»á³öÏÖЧÂʼ«ÆäÂýµÄÇé¿ö£¬ÎÒÔÚÕâ¶Îʱ¼ä×ö³öµÄһЩ²âÊÔÒ²¼°Ò»Ð©¾­Ñ飬Óë´ó¼Ò·ÖÏí£¬Èç¹ûÓдíµÄµØ·½£¬»¹ÇëÖ¸³ö¡£
¾­¹ý²âÊÔ£¬ÎÒÃǻᷢÏÖÈçϵÄÇé¿ö»òÕß˵µÄ½áÂÛ£¬Èç¹ûÄúµÄ²âÊÔ½á¹ûÓëÎҵIJ»·û£¬Çë˵Ã÷Ô­Òò£¬ÒÔ±ãÏ໥ѧϰ¡£
1£©µ±Ò»¸ö½Ï´óµÄHTML×Ö· ......

JavascriptÃæÏò¶ÔÏó±à³Ì£¨¶þ£©£º¼Ì³Ð


ZT:http://www.ruanyifeng.com/blog/2010/05/object-oriented_javascript_inheritance.html
ÉÏÒ»´ÎµÄÎÄÕ£¬Ö÷Òª½éÉÜÁËÈçºÎ"·â×°"Êý¾ÝºÍ·½·¨£¬´ÓÔ­ÐͶÔÏóÉú³ÉʵÀý¡£
½ñÌìÒª½éÉܵÄÊÇ£¬¶à¸öÔ­ÐͶÔÏóÖ®¼äÈçºÎ"¼Ì³Ð"¡£
±ÈÈ磬ÏÖÔÚÓÐÒ»¸ö"¶¯Îï"¶ÔÏó£¬
¡¡¡¡function Animal(){
¡¡¡¡¡¡¡¡this.species = "¶¯Îï";
¡¡¡¡}
»¹ÓÐ ......

JavaScriptµÄBASE64

**
* ÎÒÔÚÍøÉÏ¿´µ½¹ýºÜ¶àBASE64µÄJavaScriptËã·¨£¬¶¼¾õµÃ²»ÂúÒ⣬ÓÚÊÇ×Ô¼ºÐ´ÁËÒ»¸ö£¬ÔÚÕâÀï·ÖÏíһϡ£
* ÎҵĴúÂëÔÚÖÊÁ¿µÄЧÂʶ¼½Ï¸ß£¬Ã»ÓÐһЩÈßÓàµÄ²Ù×÷¡£×ÜÌåÀ´½²ÎÒ¾õµÃ·Ç³£²»´í¡£
* Èç¹û´ó¼ÒÓÐʲô²»¶®µÄµØ·½¿ÉÒÔÎÊÎÒ¡£
*/
var BASE64={
    /**
     * ´Ë±äÁ¿Îª±àÂëµÄ ......

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

Dynamic Scopes  ¶¯Ì¬×÷ÓÃÓò
    Both the with statement and the catch clause of a try-catch statement, as well as a function containing eval_r(), are all considered to be dynamic scopes. A dynamic scope is one that exists only through execution of code and therefore cannot be det ......

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

Nested Members  ǶÌ׳ÉÔ±
    Since object members may contain other members, it's not uncommon to see patterns such as window.location.href in JavaScript code. These nested members cause the JavaScript engine to go through the object member resolution process each time a dot is ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ