This is an hack that leverages the jquery team to add HTML5 new tags to the IE6-8!
Function createsafefragment (document) {var list = nodenames. split ("|"), safefrag = document. createdocumentfragment (); If (safefrag. createelement) {While (list. length) {safefrag. createelement (list. pop () ;}} return safefrag ;}
However, after ie9, there will be no createelement Method for document fragments. But we can change it to document. createelement ("script.
However, after ie10, if the file fragment is not inserted into the DOM tree, no request will be sent, which is consistent with the behavior of other standard browsers. Therefore, it is a war of consumption to fight against the browser. People can continue to upgrade and kill your heack flash.
The problem with IE is that the first parse is not necessarily the first onload, and the early onload of IE is simulated by onreadystatechange. In addition, IE6 also enjoys base tags, which forces us to insert (insertbefore) in reverse order ).
var frag = document. createdocumentfragment () var script = frag. createelement ('script') frag. moduleid = "Lang" script. onreadystatechange = function () {console. log (this. parentnode. nodetype); // 11 console. log (this. parentnode. moduleid); // Lang // obtain the module ID, and then associate it with Lang. the factory in JS is bound together with document. getelementsbytagname ("head") [0]. appendchild (frag)} script. src = 'lang. js'; frag. appendchild (SCRIPT)