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:
Igor Minar 2017-05-27 11:44:53 -07:00 committed by GitHub
parent b8b91d3418
commit aa683a765d
1 changed files with 12 additions and 27 deletions

View File

@ -37,36 +37,21 @@
<!-- End Google Analytics -->
<script>
window.onerror = function (message, url, lineNo, colNo, error) {
var container = document.createElement('div');
container.style.color = 'red';
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) {
/**
* Send a blocking request to fetch polyfill. We call this only on non-evergreen browsers.
*/
function polyfillBrowser(polyfillUrl) {
var script = document.createElement('script');
script.src = 'generated/ie-polyfills.min.js';
script.src = polyfillUrl;
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>
</head>
<body>