Menu

Tech tip - 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

There are more tips at: bbingo.xyz/t

Posted by Bert Beckwith 2025-04-10 Labels: javascript

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.