javascript - Possible preventing repaint when dynamically inserting script? -
as i've understood browser freeze dom rendering when sees script tag , continues once has processed it. when inserted external javascript file (typekit) directly in html seemed case, i'm including dynamically causes repaint of window. possible fixing issue?
i'm playing around yui3 , yes know y.get.script works wanted try without framework well. using framework function causes same sort of repaint.
live example:
with loader: http://oxy.fi/oxy/ (and oxy/without_loader.php, not allowed post more 1 link)
yui().use(function(y) { var modules = { modernizr: { head: true, js: ["scripts/modernizr-1.5.min.js"] }, typekit: { head: true, js: ["http://use.typekit.com/xxxxxxx.js"], onsuccess: function () { try{ typekit.load(); } catch (e) {} } } }; for(var index in modules) { var module = modules[index], css = module.css, js = module.js; delete module.js; delete module.css; if(module.head) { var head = document.getelementsbytagname('head')[0], i=0; while(js[i]) { var script = document.createelement("script"); script.type = "text/javascript", script.src = js[i]; if(i === js.length-1 && module.onsuccess) { script.onload = module.onsuccess; } head.appendchild(script); i++; } } else { var obj = y.get.script(js, module); } }
});
Comments
Post a Comment