Created
April 9, 2024 16:14
-
-
Save westonruter/0cc169156302d3012f1cfdfb06ab32fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HTTP Archive query for how often the mediaelement-core script is on a WordPress page. | |
# | |
# WPP Research, Copyright 2024 Google LLC | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# https://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
CREATE TEMP FUNCTION HAS_SCRIPT(handle STRING, custom_metrics STRING) RETURNS BOOL LANGUAGE js AS | |
# language=javascript | |
''' | |
/** | |
* Get whether a script is present. | |
* | |
* @param {string} handle | |
* @param {object} data | |
* @param {object} data.cms | |
* @param {object} data.cms.wordpress | |
* @param {Array<{handle: string}>} data.cms.wordpress.scripts | |
* @return {boolean} | |
*/ | |
function hasScript(handle, data) { | |
for (const script of data.cms.wordpress.scripts) { | |
if (script.handle === handle) { | |
return true; | |
} | |
} | |
return false; | |
} | |
try { | |
const data = JSON.parse(custom_metrics); | |
return hasScript(handle, data); | |
} catch (e) {} | |
return false; | |
'''; | |
WITH script_presence AS ( | |
SELECT | |
HAS_SCRIPT("mediaelement-core", custom_metrics) AS has_script, | |
FROM | |
`httparchive.all.pages`, | |
UNNEST(technologies) AS technology | |
WHERE | |
date = CAST("2024-03-01" AS DATE) AND | |
client = "mobile" AND | |
technology.technology = "WordPress" | |
) | |
SELECT | |
has_script, | |
COUNT(has_script) AS count, | |
FROM | |
script_presence | |
GROUP BY | |
has_script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Results:
So the MediaElement.js script is present on 4.7% of WordPress pages. Note this will not identify ME.js on pages that that have optimization plugins which concatenate scripts.