lighthouse-plugin-publisher-ads/utils/graph.js
/**
 * Adds all XHRs and JSONPs initiated by the given script if they are critical.
 * @param {NetworkRequest} scriptReq
 * @param {NetworkRequest} parentReq
 * @param {NetworkSummary} networkSummary
 * @param {Set<NetworkRequest>} criticalRequests Known critical requests. This
 *     method may mutate this set to add new requests.
 */
Adds all XHRs and JSONPs initiated by the given script if they are critical.
@param {NetworkRequest} scriptReq
@param {NetworkRequest} parentReq
@param {NetworkSummary} networkSummary
@param {Set} criticalRequests Known critical requests. This
method may mutate this set to add new requests.
Adds all XHRs and JSONPs initiated by the given script if they are critical . @param { NetworkRequest } scriptReq @param { NetworkRequest } parentReq @param { NetworkSummary } networkSummary @param { Set } criticalRequests Known critical requests . This method may mutate this set to add new requests .
function addInitiatedRequests(
  scriptReq, parentReq, networkSummary, criticalRequests) {
  const initiatedRequests = networkSummary.allRecords
      .filter((r) => r.resourceType != undefined)
      .filter((r) => ['Script', 'XHR'].includes(r.resourceType || '') &&
          r.endTime < parentReq.startTime)
      .filter((r) => r.initiatorRequest == scriptReq ||
        getNetworkInitiators(r).includes(scriptReq.url));
  for (const initiatedReq of initiatedRequests) {
    const blocking =
      initiatedReq.resourceType == 'XHR' &&
      isXhrCritical(initiatedReq, networkSummary, criticalRequests);
    if (blocking) {
      linkGraph(networkSummary, initiatedReq, criticalRequests);
    }
  }
}
function addInitiatedRequests ( scriptReq , parentReq , networkSummary , criticalRequests ) { const initiatedRequests = networkSummary . allRecords . filter ( ( r ) => r . resourceType != undefined ) . filter ( ( r ) => [ 'Script' , 'XHR' ] . includes ( r . resourceType || '' ) && r . endTime < parentReq . startTime ) . filter ( ( r ) => r . initiatorRequest == scriptReq || getNetworkInitiators ( r ) . includes ( scriptReq . url ) ) ; for ( const initiatedReq of initiatedRequests ) { const blocking = initiatedReq . resourceType == 'XHR' && isXhrCritical ( initiatedReq , networkSummary , criticalRequests ) ; if ( blocking ) { linkGraph ( networkSummary , initiatedReq , criticalRequests ) ; } } }
Adds all XHRs and JSONPs initiated by the given script if they are critical.
Adds all XHRs and JSONPs initiated by the given script if they are critical .
// TODO(warrengm): Check for JSONP and Fetch requests.