That does indeed work. Pretty neat. For anyone trying, here is basically all you need:
data:text/html,<script crossorigin="anonymous" integrity="..." src="...">
In total that should be a lot smaller than the linked codegolf answer.