Skip to content

Instantly share code, notes, and snippets.

@aFarkas
Last active April 15, 2021 20:07
Show Gist options
  • Save aFarkas/11315175 to your computer and use it in GitHub Desktop.
Save aFarkas/11315175 to your computer and use it in GitHub Desktop.
minimal html5shiv
(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);
(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);
@jtwebb
Copy link

jtwebb commented Jun 25, 2015

@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