`
iloveoracle
  • 浏览: 119542 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

Speed up your JavaScrip 2[]

    博客分类:
  • java
阅读更多
    <div class="blog_content">这篇是nicholas讨论如果防止脚本失控的第二篇,主要讨论了如何重构嵌套循环、递归,以及那些在函数内部同时执行很多子操作的函数。基本的思想和上一节chunk()那个例子一致,如果几个操作没有特定的执行顺序,而且互相不是依赖关系,我们就可以通过异步调用的方式加以执行,不止可以减少执行的次数,还可以防止脚本失控。本文还介绍了通过memoization技术取代递归的方法。
<div>【原文标题】speed up your javascript, part 2<br>【原文作者】nicholas c. zakas<br><br>以下是对原文的翻译:<br><br>上周我在《too much happening in a loop》(译文:如何提升javascript的运行速度之循环篇(一))这篇文章中介绍了javascript运行时间过长的第一个原因。相似的情况有时也出现在函数的定义上,函数也可能因为使用不当而过载使用。通常情况是函数内包含了过多的循环(不是在循环中执行了过多的内容),太多的递归,或者只不过是太多不相干但又要一起执行的操作。<br><br>太多的循环经常是以嵌套的形式出现,这种代码会一直占用javascript引擎直至循环结束。这方面有一个非常著名的例子,就是使用冒泡算法排序。由于 javascript有内置的sort()方法,我们没有必要使用这种方式进行排序,但我们可以借助这个算法理解嵌套循环占用资源的症结所在,从而避免类似情况的发生。下面是一个在javascript使用冒泡排序法的典型例子:<br>
0
0
分享到:
评论

相关推荐

    Beginning JavaScript, 4th Edition

    to-date JavaScript programming techniquesContinuing in the superlative tradition of the first three editions, Beginning JavaScript, Fourth Edition, gets you up to speed on all the new advances in ...

    Mastering.JavaScript.High.Performance.1784397296

    Next, you will move on to learn about DOM optimization, JavaScript promises, and web workers to better break up your large codebase. You will also learn about JavaScript performance on mobile ...

    如何提升JavaScript的运行速度(函数篇).doc

    Zakas 于 2009 年 1 月 20 日在个人网站上发表的《Speed up your JavaScript, Part 2》。本文主要讨论了如何重构嵌套循环、递归,以及那些在函数内部同时执行很多子操作的函数,以提高 JavaScript 的运行速度。 ...

    [JavaScript] JavaScript 从入门到精通 (英文版)

    Speed up and simplify app development with jQuery Quickly retrieve data from a server using AJAX requests Adapt your app for mobile devices with jQuery Mobile Build Windows 8 apps using HTML, CSS, and...

    Beginning JavaScript with DOM Scripting and Ajax: Second Editon

    This completely updated second edition covers everything you need to know to get up-to-speed with JavaScript development and add dynamic enhancements to web pages, right from the basics. As well as ...

    Beginning JavaScript with DOM Scripting and Ajax (pdf + ePub)

    This completely updated second edition covers everything you need to know to get up-to-speed with JavaScript development and add dynamic enhancements to web pages, right from the basics. As well as ...

    Web性能优化系列 10个提升JavaScript性能的技巧

    当谈到 JS 性能的时候,Zakas差不多就是你要找的,2010年六月他在Google Tech Talk发表了名为《Speed Up Your Javascript》的演讲。 但 Javascript 性能优化绝不是一种书面的技术,Nicholas 的技术演进列出了10条...

    JavaScript 圣经第5版-Javascript编程宝典--黄金版 .rar

    This book will bring programmers and non-technical professionals, including casual programmers and scripters, painlessly up to speed on all aspects of mastering JavaScript. Key topics include ...

    JavaScript Programmers Reference

    who are just learning the language and want to come up to speed quickly. In either case we assume you have at least a basic background in programming. Chapter 1, in particular, assumes you are coming...

    JavaScript 提升运行速度之循环篇 译文

    原文标题:Speed up your JavaScript, Part 1 原文作者:Nicholas C. Zakas 在我 上一篇帖子 (译文 ) 中,谈到了各个浏览器究竟会在什么情况下弹出脚本失控提示,对于Internet Explorer 来说,当浏览器执行了数量...

    PhoneGap: Beginner’s Guide

    You will find plenty of fully explained code and ample screenshots in the book to ease and speed up your understanding. This book is for developers, ideally with web development experience, who are ...

    PhoneGap Beginners Guide Sep 2011

    You will find plenty of fully explained code and ample screenshots in the book to ease and speed up your understanding. This book is for developers, ideally with web development experience, who are ...

    ReactJS.Blueprints.1785886541

    Learn how to speed up your development process and save valuable time Work though step-by-step tutorials that provide easy-to-understand solutions to real-world problems Book Description The ...

    React.Native.Blueprints.epub

    Use external modules to speed up the development and maintenance of your projects Explore the different UI and code patterns to be used for iOS and Android Understand the best practices which can be ...

Global site tag (gtag.js) - Google Analytics