如何获取我的页面上使用的外部 JavaScript 列表


How to get the list of the external JavaScript used on my page

我想找出任何给定网页上使用的JavaScript列表,我还需要知道,如果包含的任何JS调用任何其他JS。

例如:我们有 www.test.com,我们有XYZ.js包含在 test.com 中,现在是XYZ.js对某个pqr.js的调用。 所以我需要同时了解 xyz.js 和 pqr.js。

我正在使用PHP作为脚本语言。

如果一个javascript文件需要另一个javascript文件,那么你必须将所需的javascript文件包含在你的页面中。

您的 JavaScript 文件

无法在其中导入另一个 JavaScript 文件。

因此,您可以通过jQuery直接选择页面上的脚本标签。

$("script[type='text/javascript']").each(function(index, scriptElement){
//do your code here counter++

})

其中索引是每个 scriptElement 的索引,scriptElement 是当前 scriptElement。