optimizing document loading order