Dynamically Defined Behavior
From Zanecorpwiki
Javascript is one of the areas where bytes still matter. Not the extent where we need to butcher our coding in order to save a variable declaration, but enough so that low-cost changes that save significant bytes should be considered.
One such change which saves bytes and can make the code more readable is using different files to dynamically define behavior. This is similar to creating a base object which is then sub-classed, except that one is actually defining a single class in multiple files. Something we may not think of because it's impossible in some languages, like Java, but can be very useful.
For example, if we had a search widget which implements support for paging and a page that will never use that paging, then we could break up the search widget definition into two files: searchwidget.js and searchwidget-paging.js. When we need paging, we load both files, when we don't, we omit the paging extensions and save ourselves the bytes.
References
Kibbles Programming Style:Javascript by Dog Food Software (disclaimer: that's my company).


