I've wondered in the past why there isn't something like:
<script src="https://elsewhere.example.com" digest="<SHA-$foo>" />
that refuses to load the referenced script unless it matches the specified digest/signature.Using anything from sources you don't trust is a bad idea, but even trustworthy partners can be exploited to attack your site as well.
It would mean coordinating updates of the digest to all referencing sites though, which might make it practically impossible.