Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function initiatedByInlineScript(record) {
if (record.initiator.type !== 'script') {
// Initiated by some other means, e.g. preload link or static script tag.
return false;
}
const initiators = PageDependencyGraph.getNetworkInitiators(record);
if (initiators.length !== 1 || initiators[0] !== record.documentURL) {
// Depends on some other script.
return false;
}
return true;
}
.filter((r) => r.initiatorRequest == scriptReq ||
getNetworkInitiators(r).includes(scriptReq.url));