1. Introduction
A document can request the user agent that the default speculative parsing behavior is not used, by using the Prefer-No-Speculative-Parsing
HTTP header. This header is a HTTP structured field whose value must be Boolean.
The consequence of using this header is that the resulting Document’s active speculative HTML parser might be set to null
. This header indicates only a preference from the Document on how the speculative HTML parser may behave, which the user agent can choose to ignore. In terms of observable effects, this means that any fetches originating from speculative HTML parser may be avoided and any time spent in speculative parsing may be reduced. Resources that were being fetched as part of a speculative fetch, will then be fetched as part of the normal document parsing. Behind the scenes, this preference can allow user agents to skip the time spent in speculative parsing, and deallocate any implementation specific resources corresponding to speculative parsing for additional efficiency.
2. Modifications to HTML’s Speculative HTML parsing
-
Modify HTML § 13.2.8 Speculative HTML parsing to add the following line:
-
Each
Document
has a prefer no speculative HTML parsing boolean. It is initiallyfalse
.
-
-
Rewrite step 1 of start the speculative HTML parser to:
-
Optionally, return. The user agent may especially wish to return if parser’s
Document
's prefer no speculative HTML parsing istrue
, as that indicates theDocument
prefers to opt out of speculative HTML parsing.
-
3. Modifications to Document creation
-
Modify create and initialize a Document object under HTML § 7.5.1 Shared document creation infrastructure section by inserting the following steps between the current step 9 and 10:
-
Let preferNoSpeculativeHTMLParsingHeader be the result of get a structured field value given
Prefer-No-Speculative-Parsing
from navigationParams’s response's header list. -
Let preferNoSpeculativeHTMLParsing be
true
if preferNoSpeculativeHTMLParsingHeader is notnull
and preferNoSpeculativeHTMLParsingHeader[0] is the booleantrue
; otherwisefalse
.
-
-
Modify the current step 10 to set document’s prefer no speculative HTML parsing to preferNoSpeculativeHTMLParsing.