-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query to access third-party render-blocking script #30
Comments
Initial draft for the query.
cc. @felixarntz |
@mukeshpanchal27 It looks like this query is based on https://almanac.httparchive.org/en/2022/javascript#requests? Please provide such sources for reference :) I'm not familiar with the nature of the CMS Almanac-specific tables Last but not least, I see you formatted the query via the BigQuery formatter, which generally is good, however it sometimes formats some parts in a weird way, so in such cases we should manually fix this. For example, this is unnecessarily hard to read:
Would be simpler as:
Feel free to make those changes and open a draft pull request. Better to review in there, not in the issue. |
Thanks @felixarntz, for the comment. The The query format was also corrected. |
@felixarntz @mukeshpanchal27 there is a slight issue with this approach- The goal here is to study third-party scripts that are render-blocking.
Eg. We can get both the information from the lighthouse report but traversing it is a bit expensive. I have come up with a draft query below: CREATE TEMP FUNCTION
getCountRenderBlockingTPJS(lighthouseItems STRING,
fcp FLOAT64,
pageUrl STRING)
RETURNS INT64
LANGUAGE js AS '''
try {
const networkItems = JSON.parse(lighthouseItems);
let countRenderBlockingTPJS = 0
for(const item of networkItems ) {
// network-items are arranges in order of start time.
// render-blocking resources start before fcp
// network can be very large, faster we break faster is the query
if(item.startTime > fcp) break;
if( item.resourceType == "Script" &&
!item.url.startsWith(pageUrl) && // to determine third-party
(item.priority == "VeryHigh" || item.priority == "High") //render-blocking
)
{
countRenderBlockingTPJS++;
}
}
return countRenderBlockingTPJS
} catch (e) {
return -1;
}
''';
SELECT
client,
total_wp_sites,
with_3pJS_render_blocking,
(total_wp_sites-with_3pJS_render_blocking) AS without_3pJS_render_blocking,
CONCAT(ROUND(with_3pJS_render_blocking*100/total_wp_sites, 3),' %') AS opportunity
FROM (
SELECT
lh._TABLE_SUFFIX AS client,
COUNT(lh.url) AS total_wp_sites,
COUNTIF( getCountRenderBlockingTPJS( JSON_EXTRACT(lh.report, '$.audits.network-requests.details.items'),
CAST( JSON_EXTRACT_SCALAR(lh.report, '$.audits.first-contentful-paint.numericValue') AS FLOAT64 ),
lh.url) > 0 ) AS with_3pJS_render_blocking
FROM
`httparchive.technologies.2022_12_01_*` AS tech
JOIN
`httparchive.lighthouse.2022_12_01_*` AS lh
ON
tech.url = lh.url
WHERE
app = 'WordPress'
AND category = 'CMS'
AND lh._TABLE_SUFFIX = tech._TABLE_SUFFIX
GROUP BY
lh._TABLE_SUFFIX ) Result obtained (it took ~20 mins for the result):
|
For the query use below references:
The text was updated successfully, but these errors were encountered: