fix(aio): add polyfill for GoogleBot (#17062)
I chose to use unknown=polyfill option as per recommendation found at https://github.com/Financial-Times/polyfill-service/issues/852#issuecomment-272097936
This commit is contained in:
parent
b8b91d3418
commit
aa683a765d
|
@ -37,36 +37,21 @@
|
||||||
<!-- End Google Analytics -->
|
<!-- End Google Analytics -->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
window.onerror = function (message, url, lineNo, colNo, error) {
|
/**
|
||||||
var container = document.createElement('div');
|
* Send a blocking request to fetch polyfill. We call this only on non-evergreen browsers.
|
||||||
|
*/
|
||||||
container.style.color = 'red';
|
function polyfillBrowser(polyfillUrl) {
|
||||||
container.style.position = 'fixed';
|
|
||||||
container.style.background = '#eee';
|
|
||||||
container.style.padding = '2em';
|
|
||||||
container.style.top = '3em';
|
|
||||||
container.style.left = '1em';
|
|
||||||
|
|
||||||
var msg = document.createElement('pre');
|
|
||||||
msg.innerText = [
|
|
||||||
'UA: ' + window.navigator.userAgent,
|
|
||||||
'Message: ' + message,
|
|
||||||
'URL: ' + url,
|
|
||||||
'Line: ' + lineNo,
|
|
||||||
'Column: ' + colNo,
|
|
||||||
'Stack: ' + (error && error.stack)
|
|
||||||
].join('\n');
|
|
||||||
|
|
||||||
container.appendChild(msg);
|
|
||||||
|
|
||||||
setTimeout(function() {document.body.appendChild(container)}, 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (window.document.documentMode) {
|
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
script.src = 'generated/ie-polyfills.min.js';
|
script.src = polyfillUrl;
|
||||||
document.head.appendChild(script);
|
document.head.appendChild(script);
|
||||||
}
|
}
|
||||||
|
if (window.document.documentMode) {
|
||||||
|
// polyfill IE11
|
||||||
|
polyfillBrowser('generated/ie-polyfills.min.js');
|
||||||
|
} else if (!Object.assign) {
|
||||||
|
// polyfill googlebot
|
||||||
|
polyfillBrowser('https://cdn.polyfill.io/v2/polyfill.min.js?unknown=polyfill');
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
Loading…
Reference in New Issue