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:
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.<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?
API stands for Application Programming Interface. An API is a set of pre-built programs that can be used with the help of JavaScript. APIs are used to implement already written code to fulfill the needs of the project you are working on. Let us discuss some useful and popular APIs provided by HTML5.
API stands for Application Programming Interface. A Web API is an application programming interface for the Web. A Browser API can extend the functionality of a web browser. A Server API can extend the functionality of a web server.
API stands for Application Programming Interface and is a concept that is not limited or specific to JavaScript, but is used in almost all web application languages. Being a web developer, it is expected that you know about API, so let's try to understand the concept first.
APIs in client-side JavaScript Client-side JavaScript, in particular, has many APIs available to it — these are not part of the JavaScript language itself, rather they are built on top of the core JavaScript language, providing you with extra superpowers to use in your JavaScript code.
window.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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With