measure client-side page-speed stats
This commit is contained in:
parent
03dda8144c
commit
f88445e639
2 changed files with 34 additions and 1 deletions
|
@ -3,7 +3,7 @@ class Page extends BasePage
|
|||
{
|
||||
public function render()
|
||||
{
|
||||
global $config;
|
||||
global $config, $user;
|
||||
|
||||
$theme_name = $config->get_string('theme', 'default');
|
||||
$data_href = get_base_href();
|
||||
|
@ -63,6 +63,38 @@ $header_html
|
|||
webpMachine.polyfillDocument()
|
||||
});
|
||||
</script>
|
||||
<script src="/themes/rule34v2/prebid-ads.js"></script>
|
||||
<script>
|
||||
function makeid(length) {
|
||||
var result = '';
|
||||
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
var charactersLength = characters.length;
|
||||
for ( var i = 0; i < length; i++ ) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function stat(ob) {
|
||||
ob._ = makeid(10);
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "/stat.txt?" + new URLSearchParams(ob).toString(), true);
|
||||
xhr.send();
|
||||
}
|
||||
setTimeout(function(){
|
||||
var t = window.performance.timing;
|
||||
stat({
|
||||
"v": 1,
|
||||
"class": "{$user->class->name}",
|
||||
"block": window.canRunAds === undefined,
|
||||
"proto": window.location.protocol,
|
||||
"responseStart": t.responseStart - t.fetchStart,
|
||||
"responseEnd": t.responseEnd - t.fetchStart,
|
||||
"domLoading": t.domLoading - t.fetchStart,
|
||||
"domInteractive": t.domInteractive - t.fetchStart,
|
||||
"domComplete": t.domComplete - t.fetchStart,
|
||||
})
|
||||
}, 3000);
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
|
1
themes/rule34v2/prebid-ads.js
Normal file
1
themes/rule34v2/prebid-ads.js
Normal file
|
@ -0,0 +1 @@
|
|||
var canRunAds = true;
|
Reference in a new issue