Adding short names for built-in functions

 I add short names for frequently used built-in functions, when 'minifying' my game.


I use 'sed' to append code like this to the start of my game:


    Array.prototype.p=Array.prototype.push

    Math.f=Math.floor

    document.ce=document.createElement

    Node.prototype.ac = Node.prototype.appendChild

    var w=window;w.st=w.setTimeout;


I then change the code like this:


    sed -e 's/\.push(/.p(/g' 


But, I have not found a way of shortening the property 'Node.nextSibling'.


Modifying the DOM may not work in old versions of Internet Explorer.


I get annonyed when I see repeated code when I look through my game's code after I have 'minified' it





Comments

Popular posts from this blog

Problem with mobile testing tool

Coding in small steps can be boring

Removing unnecessary 'abbr' tags and links