易截截图软件、单文件、免安装、纯绿色、仅160KB

[翻译]High Performance JavaScript(016)

Regular Expression Optimization  正则表达式优化
    Incautiously crafted regexes can be a major performance bottleneck (the upcoming section, "Runaway Backtracking" on page 91, contains several examples showing how severe this can be), but there is a lot you can do to improve regex efficiency. Just because two regexes match the same text doesn't mean they do so at the same speed.
    粗浅地编写正则表达式是造成性能瓶颈的主要原因(后面“回溯失控”一节有一些例子说明这是多么严重的问题),但还有很多可以改进正则表达式效率的地方。两个正则表达式匹配相同的文本并不意味着他们具有同等的速度。
    Many factors affect a regex's efficiency. For starters, the text a regex is applied to makes a big difference because regexes spend more time on partial matches than obvious nonmatches. Each browser's regex engine also has different internal optimizations.
    许多因素影响正则表达式的效率。首先,正则表达式适配的文本千差万别,部分匹配时比完全不匹配所用的时间要长。每种浏览器的正则表达式引擎也有不同的内部优化。
    Regex optimization is a fairly broad and nuanced topic. There's only so much that can be covered in this section, but what's included should put you well on your way to understanding the kinds of issues that affect regex performance and mastering the art of crafting efficient regexes.
    正则表达式的优化是一个相当广泛和细致入微的话题。本节讨论尽其所能,希望这些内容有助于您理解影响正则表达式性能的各种问题和掌握编写高效正则表达式的艺术。
    Note that this section assumes you already have some experience with regular expressions and are primarily interested in how to make them faster. If you're new to regular expressions or need to brush up on the basics, numerous resources are available on the Web and in print. Regular Expressions Cookbook (O'Reilly) by Jan Goyvaerts and Steven Levithan (that's me!) is written for people who like to learn by doing, and


相关文档:

Javascript检查日期格式是否合法的一种简化方法。

常规的方法是将年月日取出,然后分别判断范围,然后就判断闰年2月的天数
可以通过new Date(string)的构造,比较年月日字符是否发生变化判断。
function CheckDate(text) {
if (!text) return false;
text = text.replace(/[\/-]0?/g, "/");
if (!text.match(/^\d{4}\/\d{1,2}\/\d{1,2}$/)) return true; ......

AJAX (异步 JavaScript 和 XML)

AJAX (异步 JavaScript 和 XML) 是个新产生的术语,专为描述JavaScript的两项强大性能.这两项性
能在多年来一直被网络开发者所忽略,直到最近Gmail, Google suggest和google Maps的横空出世才使人
们开始意识到其重要性.
这两项被忽视的性能是:
* 无需重新装载整个页面便能向服务器发送请求.
* 对XML文档的解析和处理. ......

javascript实现自动求和

function total(){
var i=0;
for(j=1;j<=20;j++)
{
var step="step"+j;
if(document.getElementById(step)){
if(document.getElementById(step).checked==true)
{
i=i+parseInt(document.getElementById(step).value);
}
}
}
document.getElementById("total").innerHTML = i;
}
function Resetvalue(){
......

[翻译]High Performance JavaScript(011)

Repaints and Reflows  重绘和重排版
    Once the browser has downloaded all the components of a page—HTML markup, JavaScript, CSS, images—it parses through the files and creates two internal data structures:
    当浏览器下载完所有页面HTML标记,JavaScri ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号