SlexAxton / yepnope.js

A Script Loader For Your Conditional Builds
http://yepnopejs.com/
BSD 3-Clause "New" or "Revised" License
2.51k stars 323 forks source link

Including yepnope more than once on the page causes IE problems #204

Closed j-ro closed 10 years ago

j-ro commented 10 years ago

I'm using yepnope for help loading javascript for widgets I build, so users copy and paste a package of code including the yepnope include, such as:

<script src='http://mydomain.com/assets/yepnope154-min.js' type='text/javascript'></script><script src='http://mydomain.com/widgets/widgetcode.js'></script>

Users might embed our widgets more than once on a page, so they might have yepnope included more than once. That works fine in everything but IE (testing on IE11), where I get errors like:

Unable to get property 'insertBefore' of undefined or null reference

and

NotFoundError

If I include yepnope only once, this doesn't happen. Suggestions for how to deal with this? Can yepnope be loaded in a no conflict way like jQuery can, so double includes aren't a problem? Other ideas?

j-ro commented 10 years ago

Update here: I'm currently using this to load yepnope:

<script>window.yepnope || document.write('<script src="/assets/yepnope154-min.js"><\/script>');</script>

It would be nice not to use document.write, though, hence the noconflict request.