Code Optimization- Optimizing Source Code
Article by Port Software
San Diego, California United States
Optimize Source Code
Source Code optimization is an important but often overlooked application of the send as little data as possible principle. As a web site or application acceleration strategy, its chief benefit is that the technique can provide substantial reductions in network payloads without requiring any additional processing on the origin server.
Source code optimization should be implemented as a pre deployment step through which all additions and changes to the front end source code including markup, style sheets and client side scripts that normally pass before being uploaded to the live production site or application.
Beyond White Space Removal
While traditional white space removal the elimination of superfluous spaces, tabs, new lines, and comments can result in modest savings of to percent in typical HTML and CSS files, a code optimizer modeled after a traditional software compiler can achieve a much higher level of optimization on all text based files.
Because it possesses a site wide contextual awareness, such a tool can employ more aggressive tactics, including condensing function and variable names, re mapping lengthy identifiers and paths, and through the use of a real JavaScript parser, even streamline lines of code.
Until recently, this approach has been the exclusive domain of JavaScript experts with the time and patience to write very terse code. In addition, hand coding still presented limitations to site expansion and code readability because it maintains a single optimized code base for both development and deployment. It is both safer and more efficient to use next generation development tools like the that preserve developer friendly versions of web site files as well as the highly optimized versions exclusively for delivery on the web.
When integrated into the normal developer workflow as a final pre deployment process, optimizations can be applied to growing web sites without breaking the external references that abound in modern web front ends, including function and variable names defined or initialized in one file and referenced in another. This highly aggressive optimization approach can lead to average savings of to percent in JavaScript files and as high as percent in tested, real world cases.
A sensible objection to aggressive source code optimization is that it diminishes the readability of the code when looked at in a web browser. This is a particularly outdated objection as it adds essentially no value for end users and may, in fact, represent a security threat by making it trivially easy for competitors to copy unique client side features. Even more troubling is the fact that un optimized source code also clears the way for hackers to conduct reconnaissance on a web application by source sifting for clues to its potential vulnerabilities.
Readable and well commented code is an obvious advantage during initial development, but it is not an appropriate format in which to deliver business critical web applications.
Code optimization represents the first step in improving web site and application performance by reducing the initial network payload that a server must deliver to the end user. Once that content has been optimized on the developer side, attention shifts to how that content can be delivered in its most optimized and efficient form.
Part 1 - Web Server Performance
Part 2 - Code Optimization
Part 3 - Cache Control
Part 4 - HTTP Compression
Part 5 - Performance Optimization |