optimizing document viewer for jquery