I don't know they reasons that it was decided that foreign <script>
didn't need to be blocked, but there are many benefits of that decision.
- Not all scripts have to be hosted on your own site, and, as a corollary,
- scripts can be hosted by content delivery networks that can deliver them faster and allow the client to use cached versions of popular scripts.
- Foreign scripts allow us to have cross-domain AJAX requests via JSONP.
Also, script
tags historically predate the Same Origin Policy, so it would make sense that scripts could reference files not necessarily hosted by the same site, to be consistent with how the a
, img
, embed
, frame
and other tags also did.