Search

7/28/2007

Thirteen Simple Rules for Speeding Up Your Web Site

Thirteen Simple Rules for Speeding Up Your Web Site

1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires Header
4. Gzip Components
5. Put CSS at the Top
6. Move Scripts to the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript
11. Avoid Redirects
12. Remove Duplicate Scripts
13. Configure ETags

7/26/2007

稍微匡正一下視聽 | Jedi's BLOG | Jedi.org

稍微匡正一下視聽 | Jedi's BLOG | Jedi.org

當我們擁抱新的格式──Atom 源料時,就會發現 Atom 源料同時有 <summary> 和 <content> 兩個內容區段,


AtomEnabled / Developers / Atom Syndication Format
content
Contains or links to the complete content of the entry. Content must be provided if there is no alternate link, and should be provided if there is no summary. More info here.

summary
Conveys a short summary, abstract, or excerpt of the entry. Summary should be provided if there either is no content provided for the entry, or that content is not inline (i.e., contains a src attribute), or if the content is encoded in base64. More info here.

7/23/2007

Digital Web Magazine - Seven JavaScript Techniques You Should Be Using Today

Digital Web Magazine - Seven JavaScript Techniques You Should Be Using Today - 非常之精彩,非常之幽默。

A closure establishes a space in which any variables defined within that space are not accessible from outside that space. This also includes functions themselves, and in fact, it is only functions (changed as of JavaScript 1.7) that can provide block scope and create closures for you.


對於自己造輪子他是這樣說的
Often, when I sit down to prototype out code or build a widget, I’m almost positive someone has already accomplished what I’m about to attempt. But nevertheless, it’s worth my effort to see if I can do it better. Not every wheel is round. Nor does every round wheel have twenty-inch shiny spinners. Imagination with such a highly flexible language can take you a long way.

對於犀牛書他是這樣說的
This is the best reference on JavaScript that the tree industry has to offer.

7/17/2007

Egosurfing - Wikipedia, the free encyclopedia

Egosurfing - Wikipedia, the free encyclopedia

Egosurfing (also called vanity searching, egosearching, egogoogling, autogoogling, self-googling, or simply Googling yourself) is the practice of searching for one's own given name, surname, full name, pseudonym, or screen name on a popular search engine, to see what results appear. It has become increasingly popular with the rise of popular search engines such as Google, as well as free blogging and web-hosting services. It is sometimes combined with third-party tools such as Googlefight] when several people egosurf together.

Similarly, an egosurfer is one who surfs the Internet for his own name, to see what, if any, articles appear about himself.

7/14/2007

Advanced Javascript

Coding Horror: JavaScript: The Lingua Franca of the Web

  • Douglas * Crockford: "The JavaScript Programming Language"/1 of 4
    null: isn't anything.
    undefined: (1)the default value for variables and parameters.
    (2)the value of missing number in object.
    &&: guard operator.ll: default operator.
    在JavaScript中,用bitwise operator會慢,原因是JavaScript的number都是64 bit浮點數,沒有整
    數,所以在做bitwise operator,會先把浮點數convert成32bit整數,作bitwise,結果再convert回
    浮點數.

  • Douglas Crockford: "The JavaScript Programming Language"/2 of 4

    for (var name in object) {
    if (object.hasOwnProperty(name)) { //以免show出太多繼承來的property
    alert(name + ':' + object[name]);
    }
    }

  • Douglas Crockford: "The JavaScript Programming Language"/3 of 4
    The scope that an inner function enjoys continues even after the parent functions have returned. This is called closure.

    function fade(id) {
    var dom = document.getElementById(id);
    level = 1;
    function step () {
    var h = level.toString(16);
    dom.style.backgroundColor = '#FFFF' + h + h;
    if (level < 15) {
    level += 1;
    setTimeout(step, 100);
    }
    }
    setTimeout(step, 100);
    }


    String.prototype.trim = function () {
    return this.replace(
    /^\s*(\S*(\s+\S+)*)\s*$/, "$1");
    };


    There are four ways to call a function:
    *Function form
    functionObject(arguments)
    *Method form
    thisObject.methodName(arguments)
    thisObject["methodName"](arguments)
    *Constructor form
    new functionObject(arguments)
    *Apply form
    functionObject.apply(thisObject, [arguments])

  • Douglas Crockford: "The JavaScript Programming Language"/4 of 4
    ActionScript

    Empty strings are truthy
    keywords are case insensitive
    No Unicode support
    No RegExp
    No try
    No statement labels
    || and && return booleans
    separate operators for strings and numbers

  • Douglas Crockford: "JavaScript - The Good Stuff"
  • Douglas Crockford: "Theory of the DOM " (1 of 3)

    function walkTheDOM(node, func) {
    func(node);
    node = node.firstChild;
    while (node) {
    walkTheDOM(node, func);
    node = node.nextSibling;
    }
    }
    function getElementsByClassName(className) {
    var results = [];
    walkTheDOM(document.body, function (node) {
    var a, c = node.className, i;
    if (c) {
    a = c.split(' ');
    for (i = 0; i < a.length; i += 1) {
    if (a[i] === className) {
    results.push(node);
    break;
    }
    }
    }
    });
    return results;
    }

  • Douglas Crockford: "Theory of the DOM " (2 of 3)
    The handler takes an optional event parameter.
    Microsoft does not send an event parameter, use the global event object instead.

    function (e) {
    e = e || event;
    var target =
    e.target || e.srcElement;
    ...
    }

    Cancel Bubbling
    * e.cancelBubble = true;
    * if (e.stopPropagation) {
    e.stopPropagation();
    }

    Prevent Default Action
    * e.returnValue = false;
    * if (e.preventDefault) {
    e.preventDefault();
    }
    * return false;

  • Douglas Crockford: "Theory of the DOM " (3 of 3)
    Prevent Memory Leaks on IE 6
    * Remove all event handlers from deleted DOM nodes.
    * It must be done on nodes before removeChild or replaceChild.
    * It must be done on nodes before they are replaced by changing innerHTML.


    function purgeEventHandlers(node) {
    walkTheDOM(node, function (e) {
    for (var n in e) {
    if (typeof e[n] ===
    'function') {
    e[n] = null;
    }
    }
    });
    }
    Or you can use YUI's purgeElement method.

    function addEventHandler(node, type, f) {
    if (node.addEventListener) {
    node.addEventListener(type, f, false);
    } else if (node.attachEvent) {
    node.attachEvent("on" + type, f);
    } else {
    node["on" + type] = f;
    }
    }

  • Douglas Crockford: "Advanced JavaScript" (1 of 3)
  • Douglas Crockford: "Advanced JavaScript" (2 of 3)
  • Douglas Crockford: "Advanced JavaScript" (3 of 3)

You can download the companion slides for these presentations from the excellent Yahoo User Interface Blog.

tag: walk the dom , traverse, traversal, recursive

7/13/2007

Phonetic Alphabets

NATO Phonetic Alphabet - 就是電影裡面常看到的那一套,here's the list

Alpha
Bravo
Charlie
Delta
Echo
Foxtrot
Golf
Hotel
India
Juliet
Kilo
Lima
Mike
November
Oscar
Papa
Quebec
Romeo
Sierra
Tango
Uniform
Victor
Whiskey
X-ray
Yankee
Zulu

7/12/2007

Google Gadget API for Ajax Developers

Google Gadget API for Ajax Developers

Fortunately, Google provides a nice API for proxying, which also caches the content you're grabbing. The main call is _IG_FetchContent(url, callbackFunc). The callback function is given the contents of URL.

Art with Tables


Ajaxian » Art with Tables - 用 table 作畫,真強者現在有自動化把圖片轉成 table 了Neil Fraser: Software: Image to HTML Converter,下面的 comment 說 spammer 已經用上了,也就是用 table 把字畫出來

JavaScript的null判斷

程式語言復習札記:null 判斷 «« William’s Blog


1. 變數名稱若不存在,typeof(name) 會是 'undefined'。
2. 變數名稱若存在,但未賦予實值,則會是 null。

   
function is_null(obj)
{
if (typeof(obj) == 'undefined' || obj == null)
return true;
return false;
}

寫了一些 test case 幫助釐清

//case 0:
var a;
alert(a==null); // 'true'

//case 1:
alert(typeof a); // 'undefined'
alert(typeof a=='undefined'); // 'true'
alert(a=='undefined'); // nothing happen

//case 2:
var a;
alert(typeof a); // 'undefined'
alert(typeof a=='undefined'); //'true'
alert(a=='undefined'); // 'false'

//case 3:
var a=2;
alert(typeof a); // 'number'
alert(typeof a=='undefined'); 'false'
alert(a=='undefined'); 'false'

7/02/2007

石頭閒語:如何區分動態語言和靜態語言 - 樂多日誌

石頭閒語:如何區分動態語言和靜態語言 - 樂多日誌

If the image of program which including op code and data is static in disk before loaded, we call it 'static language'.