Fix exceptions occurring when there is no target to scroll to on dom ready