CAPO function
The httparchive.fn.CAPO
function takes an HTML response body and returns an array of objects containing the relative performance weighting for each element in the static HTML <head>
.
Learn more about using Capo on BigQuery in the capo.js docs.
Input
html
The HTML response body.
Type: STRING
Response bodies can be sourced from the response_body
field of the requests
table, or the body
field of legacy response_bodies
tables.
The HTML does not need to be complete and can contain only the <head>
element, so for faster results and to avoid hitting memory limitations of BigQuery functions, it’s recommended to extract everything before the opening <body>
tag using a regular expression like this:
Output
Capo object.
Type: ARRAY<STRUCT<vizWeight STRING, weight INT64, element STRING>>
Example usage
Static input
vizWeight | weight | element |
---|---|---|
██████████ | 9 | <title>Example</title> |
█ | 0 | <link rel="manifest" href="/manifest.json"> |
█████ | 4 | <style></style> |
███ | 2 | <script defer="" src="script.js"></script> |
███████████ | 10 | <meta charset="utf-8"> |
Live input
page | vizWeight | weight | element |
---|---|---|---|
https://www.example.com/ | ██████████ | 9 | <title>Example Domain</title> |
https://www.example.com/ | ███████████ | 10 | <meta charset="utf-8"> |
https://www.example.com/ | ███████████ | 10 | <meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
https://www.example.com/ | ███████████ | 10 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
https://www.example.com/ | █████ | 4 | <style type="text/css">...</style> |