
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
resource-loader-inspector
Advanced tools
is an inspector for resource-loader developed by englercj.
resource-loader-inspector proveides its inspecting processes as loader middleware and it enables to collect resource data size and resource amount.
Resource information is summarized as bellow;
interface Summary {
totalContentLength: number;
resourceCount: number;
contentLengthUnknown: number;
}
and loader instance may be augmented inspector.summary property that contains the summary above.
Use attach method.
The second argument indicates use of HEAD request since resource-loader uses browser api such as Image and Video those don't have data size information on it's instance.
Retrieved data is stored to augmented property inspector.summary of loader instance.
ResourceLoaderInspector.attach(loader);
...
console.log(loader.inspector.summary);
However, inspector does not care about reset() call of loader.
Users may manually recalcurate resource info as described below.
Use snapshot method.
It returns object that has exactly same schema with inspector.summary .
Resource summary is retrieved from existing resource properties.
It means no additional retrieval such as http HEAD request will occur in this method.
Note that calcurated summary is not stored to given loader instance.
const summary = ResourceLoaderInspector.snapshot(loader);
Use recollect method.
It recollects resource info from resources property of given loader instance.
This API is used when resource data is reset or whenever it is suspected not keeping atomicity beteen summary and resource data.
Collected info is stored to inspector.summary property of loader instance.
ResourceLoaderInspector.recollect(loader);
...
console.log(loader.inspector.summary);
resource-loader-inspector uses HEAD request to retrieve data size for files not downloaded via XHR such as Image, Audio and Video.
And of course this gives an impact to the application performance, so this module should be used only under the development environment.
Otherwise you can turn of the HEAD request feature by giving false to the second argument of attach and recollect method.
FAQs
inspector for resource-loader
We found that resource-loader-inspector demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.