js and css loading refactoring