dynamic-script-loading

What is causing my scripts to be requested twice while using Modernizr.load (yepnope.js)

泄露秘密 提交于 2019-11-30 00:34:01
问题 I am using yepnope.js to load javascript files dynamically,and I've noticed that my scripts appear to be loaded twice according to Firebug and Webkit Inspector. The problem is that in Firebug's Net panel (Firefox 4 latest), their response is a 200 , not a 304 . It seems to be slower than in Chrome. I have uploaded this video showing the issue. You can see how the files jquery-1.6.1.min.js and libs.js are loaded an extra time. The code I am using to do this is the following, simplified:

Dynamically load Web Components / HTML Imports?

微笑、不失礼 提交于 2019-11-29 04:08:30
How would you go about dynamically loading a web component - in response to a url route change for example? I won't know the requested component ahead of time, so could you simply use JavaScript to write the HTML import and then add the code to the page, or are there implications with this? Perhaps Google Polymer helps? Scott Miles Considering just Custom Elements, you can call document.registerElement whenever you want. So from that standpoint, you can dynamically load script using any well known method and have dynamic custom elements. Now, with respect to HTML Imports: could you simply use

Why script elements created through DOMParser do not execute?

时光怂恿深爱的人放手 提交于 2019-11-28 03:20:54
问题 I'm loading HTML in Ajax, parsing it with DOMParser and put all the childNodes of the document body into a document fragment. When I add the fragment into the current document's body, <script> tags aren't executed. I fiddled around and figured out that if I replace them with new dynamically created script tags, they get correctly executed. I would like to know WHY? E.g. var html = "Some html with a script <script>alert('test');</script>"; var frag = parsePartialHtml(html);

Dynamic script addition should be ordered?

↘锁芯ラ 提交于 2019-11-27 16:36:26
问题 I'm adding some <script> tags dynamically to the head element after page load. I understand the scripts are loaded asynchronously, but can I expect them to be parsed in the order they are added? I'm seeing the expected behaviour in Firefox, but not in Safari or Chrome. Looking at the document in Chrome developer tools and Firebug, both show the following - <html> <head> ... <script type="text/javascript" src="A.js"></script> <script type="text/javascript" src="B.js"></script> </head> ... <