New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create('<script>') doesn't create a working script element #96
Comments
It occurred to me that since |
Or wait... maybe not, since it doesn't get added to the |
If you're suggesting that they're temporarily added to a DOMFragment, then it's fine and safe. But if you're suggesting they're added to the real DOM, it doesn't matter where a script element is added, the behavior is the same. When it's added, it's made subject to execution. In all versions of IE, the browser will start fetching the script as soon as you set However, some people actually utilize the behavior that IE prefetches scripts into the cache like that, so that's not necessarily a feature to code around or avoid. But certainly you don't want scripts to execute too early because you've inserted them into the real DOM "temporarily". |
@getify yeah, I later realized that that was indeed what I was suggesting, so there's no problems... (Although, in any case, the bug isn't resolved yet, so it would still be at least temporarily moot.) As far as IE goes, do you happen to know if it also prefetches scripts with |
IE <= 9 (dunno about 10, honestly) and older webkit (aka, webkit pre Mar 2011) fetch those types of scripts. The spec now specifically forbids such fetching, so any new and spec-conforming browser will not. |
[Sorry, I think I misread what you wrote above and you actually answered that.] Also, I wonder why the spec would forbid that... seems useful to me. Do you have any mailing list links or anything about the topic? I'm interested to know more, but hate to keep cluttering the bonzo tracker. Thanks, BTW. |
nevertheless, the way to fix this is to detect that a script tag has in fact been included, and create one from scratch. perhaps i'll give this one a go... |
i've added a minimum viable solution for folks that require this functionality. it works as such for now bonzo(bonzo.create('<script src="hello.js">')).appendTo(document.body) note that it should not execute until it's appended to the live DOM. ultimately it work when the normalize stuff is in... (or with Ender now) bonzo('<script src="hello.js">').appendTo(document.body) |
Woah, cool! |
Trail starts here: https://twitter.com/getify/status/248137610113986560
I gather that while we can create script elements they don't actually work.
/cc @getify
The text was updated successfully, but these errors were encountered: