js/loader: postpone redirection handling

Redirections should not be executed unless the original request has been
terminated and removed from pending requests.

fixes #6989