media loading and page loading refactor