Fixes problem where a div does not exist when trying to execute a javascript on it