"• Literal values and local variables can be accessed very quickly, whereas array items and object members take longer. • Local variables are faster to access than out-of-scope variables because they exist in the first variable object of the scope chain. The further into the scope chain a variable is"
"• Minimize DOM access, and try to work as much as possible in JavaScript. • Use local variables to store DOM references you’ll access repeatedly. • Be careful when dealing with HTML collections because they represent the live, underlying document. Cache the collection length into a variable and use "
"1. 使元素脱离文档流 2. 对其应用多重改变 3. 把元素带回文档中 有三种基本方法可以使 DOM 脱离文档: - 隐藏元素,应用修改,重新显示 - 使用文档片段(document fragment)在当前 DOM 之外构建一个子树,再把它拷贝回文档 - 将原始元素拷贝到一个脱离文档的节点中,修改副本,完成后再替换原始元素"
"一个长度为 n 的数组最终会调用 mergeSort() 2*n-1 次,这意味着一个长度超过 1500 的数组会在 Firefox 上发生栈溢出错误。"
"One word of caution: it is not recommended to use this technique for object methods. Many object methods use this to determine the context in which they are being called, and storing a method in a local variable causes this to be bound to window. Changing the value of this leads to programmatic erro"
"Firefox, Opera, Chrome, and Safari 3+ all fire a load event when the src of a <script> element has been retrieved. You can therefore be notified when the script is ready by listening for this event:"
"If you only care about sending data to the server (with possibly a very simple response), use image beacons. Beacons are the fastest and most efficient way to send data back to the server. The server doesn’t have to send back any response body at all, so you don’t have to worry about downloading dat"
"These two functions implement a lazy-loading pattern. The first time either method is called, a check is made to determine the appropriate way to attach or detach the event handler. Then, the original function is overwritten with a new function that contains just the appropriate course of action. Th"