Last active
April 15, 2021 20:07
-
-
Save aFarkas/11315175 to your computer and use it in GitHub Desktop.
minimal html5shiv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(createElement){ | |
if(!('hidden' in createElement('a'))){ | |
'abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video'.replace(/\w+/g, function(elem){ | |
createElement(elem); | |
}); | |
var p = createElement('p'); | |
var parent = document.getElementsByTagName('head')[0] || document.documentElement; | |
p.innerHTML = 'x<style>' + | |
'article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block} ' + | |
'mark{background:#FF0;color:#000} template{display:none}' + | |
'</style>'; | |
parent.insertBefore(p.lastChild, parent.firstChild); | |
} | |
})(document.createElement); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(createElement){ | |
if(!('hidden' in createElement('a'))){ | |
'abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video'.replace(/\w+/g, function(elem){ | |
createElement(elem); | |
}); | |
} | |
})(document.createElement); |
@aFarkas Would this work just the same as the current html5shiv? I'd like to move modernizr to my footer, but need to include the shiv in the header. Is it safe (for IE8) to use this in place of the html5shiv?
And which would be better to use? minimal-1 or minimal-2?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compared sizes between gist and normal html5shiv:
dist/html5shiv-minimal.min.js
Size: 585 bytes
Gzip Size: 386 bytes
dist/html5shiv-minimal2.min.js
Size: 277 bytes
Gzip Size: 212 bytes
dist/html5shiv-printshiv.min.js
Size: 4.03 Kb
Gzip Size: 1.91 Kb
dist/html5shiv.min.js
Size: 2.43 Kb
Gzip Size: 1.24 Kb