Use SubResource Integrity Checking for External Scripts

SubResource Integrity

Recently British Airways got hacked and more than 380.000 payment cards got compromised. So how could this have happened? Imagine that BA uses some external JavaScript library. If a hacker can change this external source and add his/her own code to the library, it is a piece of cake to steal any information that the user enters on the website. So how can you avoid this hack?