(function(){

    var jsattribs = [
            "onmouseover",
            "onmouseout",
            "onmousedown",
            "onmouseup",
            "onclick",
            "ondblclick",
            "onmousemove",
            "onload",
            "onunload",
            "onbeforeunload"
    ],
    cssattribs = ["style"];

    function getAttribsSize(attribs) {
        var i = 0,
            j = 0,        
            cnt = 0,
            value = '',
            attr = '',
            els = document.getElementsByTagName('*');
        for (i = 0; i < els.length; i++) {
            for (j = 0; j < attribs.length; j++) {
                attr = attribs[j];
                value = els[i].getAttribute(attr);
                if (value && typeof value === 'string') {
                    cnt += attr.length;
                    cnt += 3; // ="..."
                    cnt += value.length;
                } 
            }

        }
        return cnt; 
    }


    function getInlineSize(tag) {
        
        var s = 0, all = document.getElementsByTagName(tag);
        for (var i = 0; i < all.length; i++) {
            s += all[i].innerHTML.length;
        }        
        return s;
    }


    var jsatt = getAttribsSize(jsattribs);
    var cssatt = getAttribsSize(cssattribs);
    


    var msg = [];
    msg.push('JS attributes (e.g. onclick): ' + jsatt + ' bytes');
    msg.push('CSS style attributes: ' + cssatt);
    msg.push('Inline JS: ' + getInlineSize('script'));
    msg.push('Inline CSS: ' + getInlineSize('style'));
    msg.push('All innerHTML: ' + document.documentElement.innerHTML.length);
    msg.push('# DOM elements: ' + document.getElementsByTagName('*').length);

    alert(msg.join("\n"));

})();
