Bringing over javascript from sufia to get pages to load, a lot of which probably needs to be pruned