41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
function loadBodyScript(src) {
|
|
var tag = document.createElement('script');
|
|
tag.src = src;
|
|
tag.async = false;
|
|
document.body.appendChild(tag);
|
|
}
|
|
|
|
// Polyfill feature checks
|
|
// [<feature check>, <polyfill path>]
|
|
var ESPath = 'js/polyfills/EcmaScript/';
|
|
var polyfills = [
|
|
[!document.body.outerHTML, 'js/polyfills/Dom/Element.outerHTML.min.js'],
|
|
[!Array.from, ESPath + 'Array.from.js'],
|
|
[!Array.isArray, ESPath + 'Array.isArray.js'],
|
|
[!Array.from, ESPath + 'Array.from.js'],
|
|
[!Array.prototype.filter, ESPath + 'Array.prototype.filter.js'],
|
|
[!Array.prototype.forEach, ESPath + 'Array.prototype.forEach.js'],
|
|
[!Array.prototype.includes, ESPath + 'Array.prototype.includes.js'],
|
|
//[!Array.prototype.map, ESPath + 'Array.prototype.map.js'],
|
|
[!Array.prototype.reduce, ESPath + 'Array.prototype.reduce.js'],
|
|
[!String.prototype.repeat, ESPath + 'String.prototype.repeat.js'],
|
|
[!String.prototype.trim, ESPath + 'String.prototype.trim.js']
|
|
];
|
|
|
|
var polyfillCount = polyfills.length;
|
|
var i = 0;
|
|
|
|
// Load polyfills based on feature checks
|
|
for (; i < polyfillCount; i++) {
|
|
if (polyfills[i][0]) {
|
|
loadBodyScript(polyfills[i][1]);
|
|
}
|
|
}
|
|
|
|
// Load the actual code
|
|
loadBodyScript('js/index.min.js');
|
|
})();
|