[翻译]High Performance JavaScript(029)
Working Around Caching Issues 关于缓存问题
Adequate cache control can really enhance the user experience, but it has a downside: when revving up your application, you want to make sure your users get the latest version of the static content. This is accomplished by renaming static resources whenever they change.
充分利用缓存控制可真正提高用户体验,但它有一个缺点:当应用程序更新之后,你希望确保用户得到静态内容的最新版本。这通过对改动的静态资源进行重命名实现。
Most often, developers add a version or a build number to filenames. Others like to append a checksum. Personally, I like to use a timestamp. This task can be automated using Ant. The following target takes care of renaming JavaScript files by appending a timestamp in the form of yyyyMMddhhmm:
大多情况下,开发者向文件名中添加一个版本号或开发编号。有人喜欢追加一个校验和。个人而言,我更喜欢时间戳。此任务可用Ant自动完成。下面的目标体通过附加一个yyyyMMddhhmm格式的时间戳重名名JavaScript文件:
<target name="js.copy">
<!-- Create the time stamp -->
<tstamp/>
<!-- Rename JavaScript files by appending a time stamp -->
<copy todir="${build.dir}">
<fileset dir="${src.dir}" includes="*.js"/>
<globmapper from="*.js" to="*-${DSTAMP}${TSTAMP}.js"/>
</copy>
</target>
Using a Content Delivery Network 使用内容传递网
A content delivery network (CDN) is a network of computers distributed geographically across the Internet that is responsible for delivering content to end users. The primary reasons for using a CDN are reliability, scalability, and above all, performance. In fact, by serving content from the location closest to the user, CDNs are able to dramatically decrease network latency.
内容传递网络(CDN)是按照地理分布的计算机网络,通过以太网负责向最终用户分
相关文档:
隐藏成员变量
在函数体内定义的变量为局部变量,离开函数就挂掉了
在函数体内使用this.成员变量名,则为window对象级变量,即全局变量
故需要这样隐藏成员变量,向外只暴露get、set函数
function testClass(name){
var _firstname=name;
return {
getname : function() {
return _fir ......
使用javascript创建Microsoft XML DOM,就可以完成这一工作.
// 装入数据.
var source = new ActiveXObject("Microsoft.XMLDOM");
source.async = false
source.load("history.xml");
// 装入样式表.
var stylesheet = new ActiveXObject("Microsoft.XMLDOM");
stylesheet.async = false
stylesheet.load( ......
第五章 Strings and Regular Expressions 字符串和正则表达式
Practically all JavaScript programs are intimately tied to strings. For example, many applications use Ajax to fetch strings from a server, convert those strings into more easily usable JavaScript objects, and ......
第八章 Programming Practices 编程实践
Every programming language has pain points and inefficient patterns that develop over time. The appearance of these traits occurs as people migrate to the language and start pushing its boundaries. Since 2005, when the term "Ajax" ......
JavaScript Minification JavaScript紧凑
JavaScript minification is the process by which a JavaScript file is stripped of everything that does not contribute to its execution. This includes comments and unnecessary whitespace. The process typically reduces the file size by ha ......