I have now posted to Github. Hopefully I described things sufficiently to be helpful!
@AndreyPopov
Bear in mind that at wiki-test.westeros.org, I have this in LocalSettings:
None of that code (except the ad code that sets cookies that I have commented out) causes a problem with the caching. So I think it's not the hook or how it inserts the code, because I don't think OLS sees that page until after the hook has run and the page is rendered and moved to be sent to the requester.
@AndreyPopov
Bear in mind that at wiki-test.westeros.org, I have this in LocalSettings:
PHP:
$wgHooks['BeforePageDisplay'][] = 'onBeforePageDisplay';
function onBeforePageDisplay(OutputPage & $out, Skin & $skin) {
$script = '<link href="https://fonts.googleapis.com/css?family=Uncial+Antiqua" rel="preload" as="style">
<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
<link href="https://fonts.googleapis.com/css?family=Uncial+Antiqua" rel="stylesheet">
<link rel="preconnect" href="https://pagead2.googlesyndication.com/" crossorigin>
<link rel="preconnect" href="https://stats.g.doubleclick.net" crossorigin>
<link rel="preconnect" href="https://images-na.ssl-images-amazon.com" crossorigin>
<link rel="preconnect" href="https://s3.amazonaws.com" crossorigin>
<meta property="fb:app_id" content="187755409648">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="twitter:card" content="summary" />
<script type="application/ld+json">
{ "@context" : "http://schema.org",
"@type" : "Organization",
"name" : "Westeros",
"url" : "http://westeros.org",
"sameAs" : [ "http://www.facebook.com/Westeros",
"http://www.twitter.com/westerosorg",
"http://www.youtube.com/Balerion300"]
}
}
</script>
<script type="text/javascript" src="//cdn.geni.us/snippet.min.js" defer></script>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function() {
var tsid =9701;
Genius.amazon.convertLinks(tsid, true, "http://buy.geni.us"); });
</script>';
## <script type="text/javascript" src="https://lngtd.com/westeros_wiki.js"></script>
global $wgContentNamespaces;
$title = $skin->getRelevantTitle();
$namespaceNumber = $title->getNamespace();
if($namespaceNumber == 0) {
$out->addHeadItem("organization", $script);
};
return true;
};