删除 "old" JSONP 脚本标签是一种好习惯吗?

Is removing "old" JSONP script tags a good practice?

如果一个程序可能会为 JSONP 调用创建多个 <script> 元素,那么在添加更多元素之前删除旧元素是否是一个好习惯?为什么?

在我的情况下,将创建的元素保存在变量中不是一个选项。

例子

如果你删除之前的调用,结果可能会看到最后这样(或者乘以一千倍):

<script src="https://example.com/script1"></script>
<script src="https://example.com/script2"></script>
<script src="https://example.com/script3"></script>

但是如果你删除以前的调用,则有必要为脚本设置一个id:

<script id="jsonp-call" src="https://example.com/script1"></script>
<!-- Then it'll become -->
<script id="jsonp-call" src="https://example.com/script2"></script>
<!-- And after that -->
<script id="jsonp-call" src="https://example.com/script3"></script>

由于 script 标签在用于 JSONP 时纯粹是一种传输机制,所以我会在它完成工作后立即清理它:在 JSONP 回调中,或者当它超时时。所以我不会让它们到处乱放,也不会等到下一个电话再去清理上一个。