*/
$wgPriorityHints = false;
+/**
+ * Ratio of requests that should get Priority Hints when the feature is enabled.
+ *
+ * @warning EXPERIMENTAL!
+ *
+ * @since 1.34
+ * @var float
+ */
+$wgPriorityHintsRatio = 1.0;
+
/**
* Enable Element Timing.
*
* @return string
*/
function toHtml( $options = [] ) {
- global $wgPriorityHints, $wgElementTiming;
+ global $wgPriorityHints, $wgPriorityHintsRatio, $wgElementTiming;
if ( func_num_args() == 2 ) {
throw new MWException( __METHOD__ . ' called in the old style' );
&& $this->width * $this->height > 100 * 100 ) {
self::$firstNonIconImageRendered = true;
- $attribs['importance'] = 'high';
- $elementTimingName = 'thumbnail-high';
+ // Generate a random number between 0.01 and 1.0, included
+ $random = rand( 1, 100 ) / 100.0;
+
+ if ( $random <= $wgPriorityHintsRatio ) {
+ $attribs['importance'] = 'high';
+ $elementTimingName = 'thumbnail-high';
+ } else {
+ // This lets us track that the thumbnail *would* have gotten high priority but didn't.
+ $elementTimingName = 'thumbnail-top';
+ }
}
if ( $wgElementTiming ) {