admin 管理员组文章数量: 1086019
I'm working on a remote JavaScript debugger and page inspector. I'm trying to find a way to programmatically get a list of all page assets (stylesheets, scripts, images, fonts, etc.) that a page loads, and pass them along to the remote inspector. I'd like to be able to edit the assets on the inspector side and pass them back to the client as well. Finally, I'd like to force asset reloads after the page has loaded (e.g. reload a stylesheet).
Are there any browser APIs or JavaScript techniques to do this?
I can think of two ways:
- Use
window.performance
to get a list of assets. Doesn't contain the resource content, however, and relies on parsing the URL for determining the type of resource that it is. I'm not sure that it includes things like CSS images as well. - Scrape/parse the page for
<style>
,<script>
,<img>
tags and look through the CSS for additional resources. Very labor intensive and error prone, and I still don't know that it contains the resource content.
Any suggestions on how to do this?
I'm working on a remote JavaScript debugger and page inspector. I'm trying to find a way to programmatically get a list of all page assets (stylesheets, scripts, images, fonts, etc.) that a page loads, and pass them along to the remote inspector. I'd like to be able to edit the assets on the inspector side and pass them back to the client as well. Finally, I'd like to force asset reloads after the page has loaded (e.g. reload a stylesheet).
Are there any browser APIs or JavaScript techniques to do this?
I can think of two ways:
- Use
window.performance
to get a list of assets. Doesn't contain the resource content, however, and relies on parsing the URL for determining the type of resource that it is. I'm not sure that it includes things like CSS images as well. - Scrape/parse the page for
<style>
,<script>
,<img>
tags and look through the CSS for additional resources. Very labor intensive and error prone, and I still don't know that it contains the resource content.
Any suggestions on how to do this?
Share Improve this question asked Jul 8, 2015 at 17:22 colbin8rcolbin8r 3523 silver badges12 bronze badges1 Answer
Reset to default 10window.performance.getEntries() is something good to start with. If you have the list, maybe you can pass them on by manually retrieving the content (you have the URL + session already). Good luck!
本文标签: javascriptIs there a browser API to get a list of page resourcesStack Overflow
版权声明:本文标题:javascript - Is there a browser API to get a list of page resources? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744074937a2529174.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论