i want to prevent loading the rest of the page and just load the -head-, in case the page be too heavy and i just need the -title- so thats a total waste. any idea if this is possible or not?
thank you
i want to prevent loading the rest of the page and just load the -head-, in case the page be too heavy and i just need the -title- so thats a total waste. any idea if this is possible or not?
thank you
2
Answers
The closest you can come is to use the
content-range
request header to ask the server for a specific number of bytes.The specifics of how to do this depends on the HTTP API (
node:http
,fetch
,axios
, etc.) you are using.Limitations:
<head>
. This is hard. For examplehttp://facebook.com
gives me 27K of data before the end of</head>
whilehttp://example.com
only has 940B.Content-Range
Another not-so-clean solution (in addition to Quentin‘s answer) is to "stream" the site to a buffer in chunks and abort once
</head>
is reached. The problem is, the last chunk could still contain more than just</head>
. Should work nonetheless: