Javascript optimization

javascript No Comments »

Link:Javascript optimization – high performance JS apps

文中作者主要是针对于Prototype,提到了从以下几个方面入手优化JS代码,提高性能

  1. 分析性能
    主要提到了使用fx的一个插件firebug,插播一个消息,现在最新的firebug beta版已经支持firefox 3
  2. 移除$$和事件绑定
    主要是移除一些重复的不必要的事件绑定
  3. 延时
    延时加载,用到的时候再加载
  4. 如果没必要不使用Prototype的functions
    Prototype中的function会执行一些其它的不必要的循环判断等,如果真的追求速度,就要限制对它的使用。
  5. 更低一级别的优化
    列举了几个低一级的优化,像什么用for 循环代替for in循环,其中推荐去看下这个string performance an analysis,这里说到长久以来推荐的使用Array.join()这种操作字符串方式与+=的分析,原来结果和理想的并不一样

更详细的内容,请看原文

Technorati : , ,
Del.icio.us : , ,
Zooomr : , ,

  • Share/Bookmark

Using Prototype to Load Javascript Files

javascript No Comments »

Link: Using Prototype to Load Javascript Files

通过prototype实现了,JS文件的自动导入。

下面是一个示例

document.observe("dom:loaded", function() {     var calendar = $("calendar");       if(calendar) {              var script = new Element("script", { type: "text/javascript", src: "/path/to/calendar.js" });               document.observe("calendar:loaded", function() { new Calendar(calendar); });                $$("head")[0].insert(script);       }});

Read the rest of this entry »

  • Share/Bookmark

[老妈厨房]仔姜鸭

food No Comments »

今天的主菜是–仔姜鸭,先来看效果

duck

原料

鸭子半只

仔姜、青椒、蒜各少许

酱油、白沙糖、盐、味精少许

Read the rest of this entry »

  • Share/Bookmark

5.12 earthquake

other No Comments »

earthquake

earthquake

earthquake

earthquake

众志成城,抗震救灾

Read the rest of this entry »

  • Share/Bookmark

Unobtrusive JavaScript with jQuery

javascript 1 Comment »

Link:Unobtrusive JavaScript with jQuery

var $ = jQuery;
$('a.sidenote').unbind().one('click', function() {
    $('<p />').load(this.href).appendTo(document.body);
    // Make the link stop being a link
    $(this).replaceWith($(this).contents());
    return false;
});
var loading = $(
   '<img alt="loading" src="http://simonwillison.net/static/2008/loading.gif" />'
).appendTo(document.body).hide()
loading.ajaxStart(function() { $(this).show() });
loading.ajaxStop(function() { $(this).hide() });

文中的一个PPT里面,讲解了一些简单的使用jQuery编写无侵入式的Javascript代码,正在学习jQuery的朋友很值得一看,强烈推荐。

  • Share/Bookmark

Special Compression

javascript No Comments »

Link:Compression using Canvas and PNG-embedded data

prototype_png

作者很有创意,上面这个充满噪点的图片,是用Prototype压缩而来的,神奇吧。读取时使用getImageData()。

不过目前只支持Firefox, Opera Beta和最近的WebKit nightlies。

Read the rest of this entry »

  • Share/Bookmark

Event compatibility tables

javascript No Comments »

Link:Event compatibility tables

event compatibility

作者对跨浏览器Javascript事件的兼容型进行了详细的测试,包括最新的IE8b1和FF3b5。对一些没有成功测试的事件也进行了详细的说明。

文章结尾还对W3C events和Microsoft events进行了测试。其中W3C events的事件,看起来真是有点奇特,浏览器支持也不是很好。

  • Share/Bookmark

Streaming AJAX Proxy

javascript No Comments »

Link:Fast, Scalable, Streaming AJAX Proxy

当需要使用Ajax跨域访问的时候,由于安全限制,需要把本地服务器作为一个代理,通过本地服务器访问外部域,把数据取回来之后,再反映到客户端上,如下图

regular_proxy

Read the rest of this entry »

  • Share/Bookmark
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in