跳到主要内容

Preload🧪

✅️️ Methods

🔨Preload.disable


🔨Preload.enable


✅️️ Events

👋Preload.prefetchStatusUpdated

当预取尝试更新时触发。

EN
Fired when a prefetch attempt is updated.
参数必填标记类型描述原文
key✔️PreloadingAttemptKey
pipelineId✔️PreloadPipelineId
initiatingFrameId✔️Page.FrameId发起预取的框架的框架ID。
ENThe frame id of the frame initiating prefetch.
prefetchUrl✔️string
status✔️PreloadingStatus
prefetchStatus✔️PrefetchStatus
requestId✔️Network.RequestId

👋Preload.preloadEnabledStateUpdated

当预加载启用状态更新时触发。

EN
Fired when a preload enabled state is updated.
参数必填标记类型描述原文
disabledByPreference✔️boolean
disabledByDataSaver✔️boolean
disabledByBatterySaver✔️boolean
disabledByHoldbackPrefetchSpeculationRules✔️boolean
disabledByHoldbackPrerenderSpeculationRules✔️boolean

👋Preload.preloadingAttemptSourcesUpdated

发送文档中所有预加载尝试的源列表。

EN
Send a list of sources for all preloading attempts in a document.
参数必填标记类型描述原文
loaderId✔️Network.LoaderId
preloadingAttemptSources✔️array[PreloadingAttemptSource]

👋Preload.prerenderStatusUpdated

当预渲染尝试被更新时触发。

EN
Fired when a prerender attempt is updated.
参数必填标记类型描述原文
key✔️PreloadingAttemptKey
pipelineId✔️PreloadPipelineId
status✔️PreloadingStatus
prerenderStatusPrerenderFinalStatus
disallowedMojoInterfacestring这用于向用户提供更多关于与预渲染不兼容并导致尝试取消的Mojo接口名称的信息。
ENThis is used to give users more information about the name of Mojo interface that is incompatible with prerender and has caused the cancellation of the attempt.
mismatchedHeadersarray[PrerenderMismatchedHeaders]

👋Preload.ruleSetRemoved

参数必填标记类型描述原文
id✔️RuleSetId

👋Preload.ruleSetUpdated

Upsert。目前,仅当规则集添加时才会触发。

EN
Upsert. Currently, it is only emitted when a rule set added.
参数必填标记类型描述原文
ruleSet✔️RuleSet

✅️️ Types

📌Preload.PrefetchStatus

TODO(https://crbug.com/1384419): 重新审视PrefetchStatus列表,并过滤掉对开发者不必要的那些项。
允许的值:PrefetchAllowed, PrefetchFailedIneligibleRedirect, PrefetchFailedInvalidRedirect, PrefetchFailedMIMENotSupported, PrefetchFailedNetError, PrefetchFailedNon2XX, PrefetchEvictedAfterBrowsingDataRemoved, PrefetchEvictedAfterCandidateRemoved, PrefetchEvictedForNewerPrefetch, PrefetchHeldback, PrefetchIneligibleRetryAfter, PrefetchIsPrivacyDecoy, PrefetchIsStale, PrefetchNotEligibleBrowserContextOffTheRecord, PrefetchNotEligibleDataSaverEnabled, PrefetchNotEligibleExistingProxy, PrefetchNotEligibleHostIsNonUnique, PrefetchNotEligibleNonDefaultStoragePartition, PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy, PrefetchNotEligibleSchemeIsNotHttps, PrefetchNotEligibleUserHasCookies, PrefetchNotEligibleUserHasServiceWorker, PrefetchNotEligibleUserHasServiceWorkerNoFetchHandler, PrefetchNotEligibleRedirectFromServiceWorker, PrefetchNotEligibleRedirectToServiceWorker, PrefetchNotEligibleBatterySaverEnabled, PrefetchNotEligiblePreloadingDisabled, PrefetchNotFinishedInTime, PrefetchNotStarted, PrefetchNotUsedCookiesChanged, PrefetchProxyNotAvailable, PrefetchResponseUsed, PrefetchSuccessfulButNotUsed, PrefetchNotUsedProbeFailed

EN
TODO(https://crbug.com/1384419): revisit the list of PrefetchStatus and filter out the ones that aren't necessary to the developers.
Allowed Values: PrefetchAllowed, PrefetchFailedIneligibleRedirect, PrefetchFailedInvalidRedirect, PrefetchFailedMIMENotSupported, PrefetchFailedNetError, PrefetchFailedNon2XX, PrefetchEvictedAfterBrowsingDataRemoved, PrefetchEvictedAfterCandidateRemoved, PrefetchEvictedForNewerPrefetch, PrefetchHeldback, PrefetchIneligibleRetryAfter, PrefetchIsPrivacyDecoy, PrefetchIsStale, PrefetchNotEligibleBrowserContextOffTheRecord, PrefetchNotEligibleDataSaverEnabled, PrefetchNotEligibleExistingProxy, PrefetchNotEligibleHostIsNonUnique, PrefetchNotEligibleNonDefaultStoragePartition, PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy, PrefetchNotEligibleSchemeIsNotHttps, PrefetchNotEligibleUserHasCookies, PrefetchNotEligibleUserHasServiceWorker, PrefetchNotEligibleUserHasServiceWorkerNoFetchHandler, PrefetchNotEligibleRedirectFromServiceWorker, PrefetchNotEligibleRedirectToServiceWorker, PrefetchNotEligibleBatterySaverEnabled, PrefetchNotEligiblePreloadingDisabled, PrefetchNotFinishedInTime, PrefetchNotStarted, PrefetchNotUsedCookiesChanged, PrefetchProxyNotAvailable, PrefetchResponseUsed, PrefetchSuccessfulButNotUsed, PrefetchNotUsedProbeFailed

返回类型:string


📌Preload.PreloadingAttemptKey

标识预加载尝试的键。
使用的URL是触发器指定的URL(即初始URL),而不是最终导航到的URL。例如,预渲染允许在尝试期间进行同源主框架导航,但尝试仍以初始URL为键。

EN
A key that identifies a preloading attempt.
The url used is the url specified by the trigger (i.e. the initial URL), and not the final url that is navigated to. For example, prerendering allows same-origin main frame navigations during the attempt, but the attempt is still keyed with the initial URL.

返回类型:object

属性必填标记类型描述原文
loaderId✔️Network.LoaderId
action✔️SpeculationAction
url✔️string
targetHintSpeculationTargetHint

📌Preload.PreloadingAttemptSource

列出预加载尝试的来源,具体包括触发该尝试的推测规则的规则集ID,以及触发尝试的<a href><area href>元素的BackendNodeId(针对由文档规则触发的情况)。单个预加载尝试可能由多个规则集和链接共同触发。

EN
Lists sources for a preloading attempt, specifically the ids of rule sets that had a speculation rule that triggered the attempt, and the BackendNodeIds of <a href> or <area href> elements that triggered the attempt (in the case of attempts triggered by a document rule). It is possible for multiple rule sets and links to trigger a single attempt.

返回类型:object

属性必填标记类型描述原文
key✔️PreloadingAttemptKey
ruleSetIds✔️array[RuleSetId]
nodeIds✔️array[DOM.BackendNodeId]

📌Preload.PreloadingStatus

预加载状态值,另请参阅 PreloadingTriggeringOutcome。此状态由 prefetchStatusUpdated 和 prerenderStatusUpdated 共享。
允许值:PendingRunningReadySuccessFailureNotSupported

EN
Preloading status values, see also PreloadingTriggeringOutcome. This status is shared by prefetchStatusUpdated and prerenderStatusUpdated.
Allowed Values: Pending, Running, Ready, Success, Failure, NotSupported

返回类型:string


📌Preload.PreloadPipelineId

Chrome 通过预加载流水线的概念统一管理不同类型的预加载行为。例如,若某站点使用 SpeculationRules 进行预渲染,Chrome 会先启动预获取,随后将其升级为预渲染。
对应的 CDP 事件会分别触发,但它们共享同一个 PreloadPipelineId

EN
Chrome manages different types of preloads together using a concept of preloading pipeline. For example, if a site uses a SpeculationRules for prerender, Chrome first starts a prefetch and then upgrades it to prerender.
CDP events for them are emitted separately but they share PreloadPipelineId.

返回类型:string


📌Preload.PrerenderFinalStatus

Prerender2 的最终状态原因列表。
允许值:ActivatedDestroyedLowEndDeviceInvalidSchemeRedirectInvalidSchemeNavigationNavigationRequestBlockedByCspMojoBinderPolicyRendererProcessCrashedRendererProcessKilledDownloadTriggerDestroyedNavigationNotCommittedNavigationBadHttpStatusClientCertRequestedNavigationRequestNetworkErrorCancelAllHostsForTestingDidFailLoadStopSslCertificateErrorLoginAuthRequestedUaChangeRequiresReloadBlockedByClientAudioOutputDeviceRequestedMixedContentTriggerBackgroundedMemoryLimitExceededDataSaverEnabledTriggerUrlHasEffectiveUrlActivatedBeforeStartedInactivePageRestrictionStartFailedTimeoutBackgroundedCrossSiteRedirectInInitialNavigationCrossSiteNavigationInInitialNavigationSameSiteCrossOriginRedirectNotOptInInInitialNavigationSameSiteCrossOriginNavigationNotOptInInInitialNavigationActivationNavigationParameterMismatchActivatedInBackgroundEmbedderHostDisallowedActivationNavigationDestroyedBeforeSuccessTabClosedByUserGestureTabClosedWithoutUserGesturePrimaryMainFrameRendererProcessCrashedPrimaryMainFrameRendererProcessKilledActivationFramePolicyNotCompatiblePreloadingDisabledBatterySaverEnabledActivatedDuringMainFrameNavigationPreloadingUnsupportedByWebContentsCrossSiteRedirectInMainFrameNavigationCrossSiteNavigationInMainFrameNavigationSameSiteCrossOriginRedirectNotOptInInMainFrameNavigationSameSiteCrossOriginNavigationNotOptInInMainFrameNavigationMemoryPressureOnTriggerMemoryPressureAfterTriggeredPrerenderingDisabledByDevToolsSpeculationRuleRemovedActivatedWithAuxiliaryBrowsingContextsMaxNumOfRunningEagerPrerendersExceededMaxNumOfRunningNonEagerPrerendersExceededMaxNumOfRunningEmbedderPrerendersExceededPrerenderingUrlHasEffectiveUrlRedirectedPrerenderingUrlHasEffectiveUrlActivationUrlHasEffectiveUrlJavaScriptInterfaceAddedJavaScriptInterfaceRemovedAllPrerenderingCanceledWindowClosedSlowNetworkOtherPrerenderedPageActivatedV8OptimizerDisabledPrerenderFailedDuringPrefetchBrowsingDataRemovedPrerenderHostReused

EN
List of FinalStatus reasons for Prerender2.
Allowed Values: Activated, Destroyed, LowEndDevice, InvalidSchemeRedirect, InvalidSchemeNavigation, NavigationRequestBlockedByCsp, MojoBinderPolicy, RendererProcessCrashed, RendererProcessKilled, Download, TriggerDestroyed, NavigationNotCommitted, NavigationBadHttpStatus, ClientCertRequested, NavigationRequestNetworkError, CancelAllHostsForTesting, DidFailLoad, Stop, SslCertificateError, LoginAuthRequested, UaChangeRequiresReload, BlockedByClient, AudioOutputDeviceRequested, MixedContent, TriggerBackgrounded, MemoryLimitExceeded, DataSaverEnabled, TriggerUrlHasEffectiveUrl, ActivatedBeforeStarted, InactivePageRestriction, StartFailed, TimeoutBackgrounded, CrossSiteRedirectInInitialNavigation, CrossSiteNavigationInInitialNavigation, SameSiteCrossOriginRedirectNotOptInInInitialNavigation, SameSiteCrossOriginNavigationNotOptInInInitialNavigation, ActivationNavigationParameterMismatch, ActivatedInBackground, EmbedderHostDisallowed, ActivationNavigationDestroyedBeforeSuccess, TabClosedByUserGesture, TabClosedWithoutUserGesture, PrimaryMainFrameRendererProcessCrashed, PrimaryMainFrameRendererProcessKilled, ActivationFramePolicyNotCompatible, PreloadingDisabled, BatterySaverEnabled, ActivatedDuringMainFrameNavigation, PreloadingUnsupportedByWebContents, CrossSiteRedirectInMainFrameNavigation, CrossSiteNavigationInMainFrameNavigation, SameSiteCrossOriginRedirectNotOptInInMainFrameNavigation, SameSiteCrossOriginNavigationNotOptInInMainFrameNavigation, MemoryPressureOnTrigger, MemoryPressureAfterTriggered, PrerenderingDisabledByDevTools, SpeculationRuleRemoved, ActivatedWithAuxiliaryBrowsingContexts, MaxNumOfRunningEagerPrerendersExceeded, MaxNumOfRunningNonEagerPrerendersExceeded, MaxNumOfRunningEmbedderPrerendersExceeded, PrerenderingUrlHasEffectiveUrl, RedirectedPrerenderingUrlHasEffectiveUrl, ActivationUrlHasEffectiveUrl, JavaScriptInterfaceAdded, JavaScriptInterfaceRemoved, AllPrerenderingCanceled, WindowClosed, SlowNetwork, OtherPrerenderedPageActivated, V8OptimizerDisabled, PrerenderFailedDuringPrefetch, BrowsingDataRemoved, PrerenderHostReused

返回类型:string


📌Preload.PrerenderMismatchedHeaders

当出现标头不匹配时,要显示的标头信息。

EN
Information of headers to be displayed when the header mismatch occurred.

返回类型:object

属性必填标记类型描述原文
headerName✔️string
initialValuestring
activationValuestring

📌Preload.RuleSet

对应 SpeculationRuleSet

EN
Corresponds to SpeculationRuleSet

返回类型:object

属性必填标记类型描述原文
id✔️RuleSetId
loaderId✔️Network.LoaderId标识规则集所关联的文档。
ENIdentifies a document which the rule set is associated with.
sourceText✔️string表示规则集的JSON源文本。如果来自&lt;script&gt;标签,则为该节点的textContent。注意,在有效情况下它是一个JSON。
另请参阅:
- https://wicg.github.io/nav-speculation/speculation-rules.html
- https://github.com/WICG/nav-speculation/blob/main/triggers.md
ENSource text of JSON representing the rule set. If it comes from &lt;script&gt; tag, it is the textContent of the node. Note that it is a JSON for valid case.
See also:
- https://wicg.github.io/nav-speculation/speculation-rules.html
- https://github.com/WICG/nav-speculation/blob/main/triggers.md
backendNodeIdDOM.BackendNodeId推测规则集可以通过内联的 &lt;script&gt; 标签或通过 'Speculation-Rules' HTTP 头的外部资源添加。对于第一种情况,我们会包含相关 &lt;script&gt; 标签的 BackendNodeId。对于第二种情况,我们会包含规则集加载来源的外部 URL,并且在 Network 域启用时还会包含 RequestId。
另请参阅:
- https://wicg.github.io/nav-speculation/speculation-rules.html#speculation-rules-script
- https://wicg.github.io/nav-speculation/speculation-rules.html#speculation-rules-header
ENA speculation rule set is either added through an inline &lt;script&gt; tag or through an external resource via the 'Speculation-Rules' HTTP header. For the first case, we include the BackendNodeId of the relevant &lt;script&gt; tag. For the second case, we include the external URL where the rule set was loaded from, and also RequestId if Network domain is enabled.
See also:
- https://wicg.github.io/nav-speculation/speculation-rules.html#speculation-rules-script
- https://wicg.github.io/nav-speculation/speculation-rules.html#speculation-rules-header
urlstring
requestIdNetwork.RequestId
errorTypeRuleSetErrorType错误信息 errorMessage 为空当且仅当 errorType 为空。
ENError information errorMessage is null iff errorType is null.
errorMessage❌️stringTODO(https://crbug.com/1425354): 用结构化错误替换此属性。
ENTODO(https://crbug.com/1425354): Replace this property with structured error.
tagstring更多详情,请参阅:https://github.com/WICG/nav-speculation/blob/main/speculation-rules-tags.md
ENFor more details, see: https://github.com/WICG/nav-speculation/blob/main/speculation-rules-tags.md

📌Preload.RuleSetErrorType

允许的值:SourceIsNotJsonObjectInvalidRulesSkippedInvalidRulesetLevelTag

EN
Allowed Values: SourceIsNotJsonObject, InvalidRulesSkipped, InvalidRulesetLevelTag

返回类型:string


📌Preload.RuleSetId

唯一标识符

EN
Unique id

返回类型:string


📌Preload.SpeculationAction

尝试的预加载类型。它对应于 mojom::SpeculationAction(尽管 PrefetchWithSubresources 被省略,因为客户端并未使用它)。
允许的值:PrefetchPrerenderPrerenderUntilScript

EN
The type of preloading attempted. It corresponds to mojom::SpeculationAction (although PrefetchWithSubresources is omitted as it isn't being used by clients).
Allowed Values: Prefetch, Prerender, PrerenderUntilScript

返回类型:string


📌Preload.SpeculationTargetHint

对应 mojom::SpeculationTargetHint。参见 https://github.com/WICG/nav-speculation/blob/main/triggers.md#window-name-targeting-hints
允许取值:Blank, Self

EN
Corresponds to mojom::SpeculationTargetHint. See https://github.com/WICG/nav-speculation/blob/main/triggers.md#window-name-targeting-hints
Allowed Values: Blank, Self

返回类型:string