How to use the lighthouse/lighthouse-core/computed/page-dependency-graph.getNetworkInitiators function in lighthouse

To help you get started, we’ve selected a few lighthouse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleads / publisher-ads-lighthouse-plugin / lighthouse-plugin-publisher-ads / audits / script-injected-tags.js View on Github external
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;
}
github googleads / publisher-ads-lighthouse-plugin / lighthouse-plugin-publisher-ads / utils / graph.js View on Github external
.filter((r) => r.initiatorRequest == scriptReq ||
        getNetworkInitiators(r).includes(scriptReq.url));