Wondered what would happen if we tried to be more efficient about variable referencing. Turns out to not be a size savings after gzip, but might be infinitesimally faster to execute due to removing two property lookups.
Original:
document.documentElement.className = document.documentElement.className.replace(/(\s|^)no-js(\s|$)/, '$1' + 'js' + '$2');
121, gzips to 96 (20% smaller)
Compressed:
document.documentElement.className=document.documentElement.className.replace(/(\s|^)no-js(\s|$)/,"$1js$2")
107, gzips to 85 (20% smaller)
Rewritten:
(function(el) {
el.className = el.className.replace(/(\s|^)no-js(\s|$)/, '$1js$2');
}(document.documentElement));
119, gzips to 115 (3% smaller)
Compressed:
(function(e){e.className=e.className.replace(/(\s|^)no-js(\s|$)/,"$1js$2")})(document.documentElement)
102, gzips to 102 (0% change)