Optimizing before rendering