Skip to content

A library to help capture sub-resource integrity errors for logging and alerts.

Notifications You must be signed in to change notification settings

jamesrwilliams/subresource-integrity-error-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Capturing invalid sub-resource integrity (SRI) errors on the client

Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.

When SRI are invalid, is a Javascript detection method/API we can use to ensure the asset has loaded and that they haven't thrown an error? I have posed this question to the fine folks on StackOverflow: "Is it possible to log client-side sub-resource integrity errors with javascript?"

Solution

Use the element onerror event handler, from there you can do some additional checks to rule out some common errors before suggesting it might be an SRI issue. You can never be 100% that it is an SRI issue.

This library is in development to simplify the process of monitoring SRI violations.

Usage

<script src="lib/sri-monitor.js"></script>
<script
  src="https://example.com/lib/you/want/to/monitor.js"
  integrity="sha256-xxxxxx" 
  onerror="monitorForSriError(this)" />

About

A library to help capture sub-resource integrity errors for logging and alerts.

Topics

Resources

Stars

Watchers

Forks