1. A method for automatically rewriting a web application to improve perceived application performance, comprising steps for: receiving a web application that is designed to be executed within a browser-type application on a client computing device (“client”); decomposing structural code units of the web application into a set of stubs and a set of corresponding bodies; determining a clustering of structural code units within the web application; constructing a new application by rewriting the web application based on the clustering, wherein stubs are used to replace corresponding structural code units in the application to reduce a total size of code that that must be transferred to the client; and wherein each stub retrieves the corresponding body when the stub is executed within the browser-type application on the client.