This is a solved problem.
Use HTTPS and use the integrity attribute.
https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/...
Also, what's more likely? Someone hacking jsDelivr/cdnjs OR some random NPM packages getting hacked?