资料下载网
首页 计算机 考试教辅
High Performance JavaScript_高性能javascript编程_中英文对照版 pdf电子书免费下载
首页 > 计算机 > javascript > High Performance JavaScript_高性能javascript编程_中英文对照版 pdf电子书免费下载

《High Performance JavaScript_高性能javascript编程_中英文对照版》pdf电子书免费下载


下载方式一:

百度网盘下载地址:https://pan.baidu.com/s/1Kf9w37La-ZsuaJY3gcUY8g
百度网盘密码:1111

下载方式二:

http://ziliaoshare.cn/Download/ac_123532_pd_HighPerformanceJavaScript_GXNjavascriptBC_ZYWDZB.zip

 


High Performance JavaScript_高性能javascript编程_中英文对照版

作者:empty

页数:349

出版社:empty

《High Performance JavaScript_高性能javascript编程_中英文对照版》介绍

JavaScript performance in the browser is arguably the most important usa bit y issue facing developers.Theproblem is complex because of the blocking nature of JavaScript, which is to say that nothing el sc can happenwhile Java Seri pt code is being executed.In fae, mos throws ers use a single process for both userinterface(UI)updates and JavaScript execution, so only one can happen at any given moment in time.The longer Java Seri pttakes to execute, the longer it takes before the browser is free to respond to userinputJavaScript在浏览器中的性能。可认为是开发者所要面对的最重要的可用性问题。此问墨因JavaScript的阻塞特征而复杂, 也就是说, Java Seri pt运行时其他的事情不脆被调苋器处理。事实上, 大多数苋器使用节进料处理U史新和Java Seri pt运行等多个任务, 同一时间只能有一个任务被执行。JavaScript运行了多长时间,那么在浏览器空闲下来响应用户输入之前的等待时间就有多长。On a basic level, this means that the very presence of as sc npt tag is enough to make the page wait for theseri pt to be parsed and executed.Whether the actual Java Seri pt code is inline with the tag or inch uded in anexternal file is irrelevant; the page download and rendering must stop and wat for these rip t to complete beforeproceeding.This is a necessary part of the page's lifecycle because the script may cause changes to the pagewhile execu ing.The typical example is using document write() in the middle of a page(as often used byadvertisements) .For example:从基本层面说, 这意味看

When the browser encounters a~seri pp tag, as in this HTML page, there is no way of knowing whether theJava Seri pt wil insert content into the cp, introduce add tonal elements, or pet haps even close the tag.Thereforethe browser stops processing the page as it comes in, executes the JavaScript code, then continues parsing andrendering the page.The same takes place for Java Seri pt loaded using the s re attr bute, the browser must firstdownload the code from the exte mal file, which takes time, and then parse and execute the code.Page renderingand user inter a eton are completely blocked during this time当器选标|添加内容, 因此, 浏览器停下来, 行此Java Sc npt代码, 然后再继续解析、翻译贝面, 同样的事情发生在快用s re属州证皖Java Seri pt的过程中。浏览器必须首先下载外部文件的代码, 这要古用一些时间, 然后解析并运行此代码。此过程中,奥面解析和用户交互是被完全阻塞的。Script Positioning脚本位置The HTM I 4 specification indicates that aortag in anHTMLdocument and may appear any number of times within each.Traditionally, script tags that are used toload external JavaScript files have appeared in the c head>, along withtags to load exte mal CSS files andother metainformation about the page.The theory was that its best to keep as many style and behaviordependencies together, loading them first so that the page will come in looking and behaving correctly.Forexample:HTML 4文档山.一个标签中, 可以在其中多次出以。传统上, 部分除此类代码外, 还包含

Though this code seems innocuous.it actually has a severe performance issue:there are three Java Seri pt filesbeing loaded in the-head.Since cach seri pt tag blocks the page from continuing to render until it has fullydownloaded and executed the JavaScript code, the perceived performance of this page will suffer.Keep in mindthat browsers don't start rendering anything on the page until the opening body tag is encountered.Puttingscripts at the top of the page in this way typically leads to a noticeable delay, often in the form of a blank whitepage, he for e the user can even begin reading or otherwise interacting with the page.To get a good understandingof how this occurs, its useful to look at a waterfall diagram showing when each resource is downloaded.FigureI-1showswheneachseript and the stylesheet file get downloaded as the page as loading虽然这些代叫看起来是无害的。但它们确实存在性能问题:在n签之节, 不会染页面的任何部分。用这种方法把脚本放在页面的项端,将导致一个可以察觉的延迟,通常表现为:页面打开时,首先显示为一幅空白的页面,而此时用户即不能阅读,也不能与页而进行交互操作,为了更好地理解此过程,我们使用瀑布图来描绘每个资源的下载过程。图1-1显示出页面加载过程中,每个脚本文件和样式表文件下载的过程。

Figure 1-1 shows an interesting patte mn.The first JavaScript file begins to download and blocks any of theother files from downloading in the meantime.Further, there is a delay between the time at which file ljs iscompletely downloaded and the time at which file 2js begins to download.That space is the time it takes for thecode contained in file l.js to fully execute.Each file must wait until the previous one has been downloaded andexecuted before the next download can begin.In the meantime, the user is met with a blank screen as the files arebeing downloaded one at at ie.This is the behavior of most major browsers today1-1是一个令人感兴趣的板板。第一个JavaScript文件开始下载, 开用塞了其他文件的下载过程、进一, fl el.js下完之后利fle2js开始下载之前有一个延时, 这是fl el.js完全运行所需的时间。每个文件必须等待前一个文件下载完成开运行完之后,才能开始自己的下载过程。当这些文件下载时,用户面对一个空白的屏幕。这就是今天大多数润览器的行为模式。InternetExplorer 8.Firefox 3.5, Safari 4, and Chrome 2 all allow parallel downloads of JavaScript files.This isgood news because the