Ori.livneh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/258227
Change subject: [WIP] Mark timing for first image load
......................................................................
[WIP] Mark timing for first image load
Add an onload snippet to the first <img> tag on the page for an image that is
bigger than 50px * 50px that uses the user timing API to mark a
'firstImageLoadEnd'
timing.
Bug: T115600
Change-Id: I1df544f6ff7bf359a8d3ee86769a9f0140018d5b
---
M NavigationTiming.php
1 file changed, 17 insertions(+), 0 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/NavigationTiming
refs/changes/27/258227/1
diff --git a/NavigationTiming.php b/NavigationTiming.php
index d58a80f..b2e4829 100644
--- a/NavigationTiming.php
+++ b/NavigationTiming.php
@@ -58,6 +58,23 @@
'SaveTiming' => 12236257,
);
+/**
+ * Add an onload snippet to the first <img> tag on the page for an image that
is bigger
+ * than 50px * 50px that uses the user timing API to mark a
'firstImageLoadEnd' timing.
+ */
+$wgHooks[ 'ThumbnailBeforeProduceHTML' ][] = function ( $thumbnail, &$attribs,
&$linkAttribs ) {
+ static $foundFirstImage = false;
+
+ if (
+ !$foundFirstImage
+ isset( $attribs['width'] ) && $attribs['width'] >= 50 &&
+ isset( $attribs['height'] ) && $attribs['height'] >= 50
+ ) {
+ $foundFirstImage = true;
+ $attribs['onload'] = "mwPerformance.mark('firstImageLoadEnd')";
+ }
+};
+
$wgHooks[ 'BeforePageDisplay' ][] = function ( &$out, &$skin ) {
$out->addModules( 'ext.navigationTiming' );
return true;
--
To view, visit https://gerrit.wikimedia.org/r/258227
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1df544f6ff7bf359a8d3ee86769a9f0140018d5b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/NavigationTiming
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits