Wow, I&#x27;ve been thinking the exact same thing for a long time.<p>In principle there&#x27;s no need to limit it to file-level granularity.  Take for example a JS minifier-compressor where human-readability isn&#x27;t a goal.  If you&#x27;re compressing a javascript file with a bunch of top-level functions, it shouldn&#x27;t matter which order the functions are expressed, thanks to hoisting.<p>Once you make that jump, it&#x27;s not even limited to re-ordering things.  The minifier-compressor could also consider all possible results of swapping singlequote and doublequote, x[&#x27;this&#x27;] vs. x.this when appropriate, and so on.