Optimization framework for web pages and applications