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

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

µÚÈýÕ  DOM Scripting  DOM±à³Ì
    DOM scripting is expensive, and it's a common performance bottleneck in rich web applications. This chapter discusses the areas of DOM scripting that can have a negative effect on an application's responsiveness and gives recommendations on how to improve response time. The three categories of problems discussed in the chapter include:
    ¶ÔDOM²Ù×÷´ú¼Û°º¹ó£¬ÔÚ¸»ÍøÒ³Ó¦ÓÃÖÐͨ³£ÊÇÒ»¸öÐÔÄÜÆ¿¾±¡£±¾ÕÂÌÖÂÛ¿ÉÄܶԳÌÐòÏìÓ¦Ôì³É¸ºÃæÓ°ÏìµÄDOM±à³Ì£¬²¢¸ø³öÌá¸ßÏìÓ¦ËٶȵĽ¨Òé¡£±¾ÕÂÌÖÂÛÈýÀàÎÊÌ⣺
• Accessing and modifying DOM elements
·ÃÎʺÍÐÞ¸ÄDOMÔªËØ
• Modifying the styles of DOM elements and causing repaints and reflows
ÐÞ¸ÄDOMÔªËصÄÑùʽ£¬Ôì³ÉÖØ»æºÍÖØÐÂÅÅ°æ
• Handling user interaction through DOM events
ͨ¹ýDOMʼþ´¦ÀíÓû§ÏìÓ¦
    But first—what is DOM and why is it slow?
    µ«Ê×ÏÈ——ʲôÊÇDOM£¿ËûΪʲôÂý£¿
DOM in the Browser World  ä¯ÀÀÆ÷ÊÀ½çÖеÄDOM
    The Document Object Model (DOM) is a language-independent application interface (API) for working with XML and HTML documents. In the browser, you mostly work with HTML documents, although it's not uncommon for web applications to retrieve XML documents and use the DOM APIs to access data from those documents.
    Îĵµ¶ÔÏóÄ£ÐÍ£¨DOM£©ÊÇÒ»¸ö¶ÀÁ¢ÓÚÓïÑԵģ¬Ê¹ÓÃXMLºÍHTMLÎĵµ²Ù×÷µÄÓ¦ÓóÌÐò½Ó¿Ú£¨API£©¡£ÔÚä¯ÀÀÆ÷ÖУ¬Ö÷ÒªÓëHTMLÎĵµ´ò½»µÀ£¬ÔÚÍøÒ³Ó¦ÓÃÖмìË÷XMLÎĵµÒ²ºÜ³£¼û¡£DOM APIsÖ÷ÒªÓÃÓÚ·ÃÎÊÕâЩÎĵµÖеÄÊý¾Ý¡£
    Even though the DOM is a language-independent API, in the browser the interface is implemented in JavaScript. Since most of the work in client-side scripting has to do with the underlying document, DOM is an important part of everyday JavaScript coding.
    ¾¡¹ÜDOMÊÇÓëÓïÑÔÎ޹صÄAPI£¬ÔÚä¯ÀÀÆ÷ÖеĽӿÚÈ´ÊÇÒÔJavaScriptʵÏֵġ£¿Í»§¶Ë´ó¶àÊý½Å±¾³ÌÐòÓëÎĵµ´ò½»µÀ£¬DOM¾Í³ÉΪJavaScript´úÂëÈÕ³£ÐÐΪÖÐÖØÒªµÄ×é³É²¿·Ö¡£
  


Ïà¹ØÎĵµ£º

phpÖеÄevalºÍJavaScriptÖеÄeval

phpÖеÄevalºÍJavaScriptÖеÄevalÇø±ð£º
Definition and Usage

¶¨ÒåºÍÓ÷¨
The eval() function evaluates a
string as PHP code.
eval()º¯ÊýµÄ×÷ÓÃÊÇ£º·µ»ØÓëPHP´úÂëÏà¶ÔÓ¦µÄ×Ö·û´®¡£
The string
must be valid PHP code and must end with semicolon.
Õâ¸ö×Ö·û´®±ØÐëÊÇÓÐЧµÄPHP´úÂ룬
²¢ÇÒ±ØÐëÒԷֺŽáÊø¡ ......

javascript×Ô¶¯ÌøתÉèÖÃ

 <script>setTimeout("redirect('<?=$url_forward?>');", <?=$ms?>);</script>
ÉèÖ÷ÖÒ³£º$page $pagesize $offset = ($page-1)*$pagesize;
$limit  = "limit $offset,$pagesize" ......

JavascriptÏÝÚå¡£¡£¡£¡£¡£¡£¡£

1.¸¡µãÔËËã
Õâ¿ÉÄÜÊÇ´ì°ÜһЩ¶Ôjavascript²»ÊìϤ²¢×¼±¸Ö´ÐÐһЩÊýѧÔËËãµÄÈ˵ÄÖ÷ÒªÔ­
Òò.
<script>  
alert(0.02 / 0.1);  //0.19999999999999998 
  
alert(1.14 * 100);  //113.99999999999999    ;)
  
......

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