SlexAxton/yepnope.js — Issue #87: Exception when on script second loading in 1.5.2
Author: nex2hex
Created: 2012-02-08 13:42:45+00:00
State: open

```javascript
yepnope({load: 'http://www.yandex.ru/dropcounters.js', callback: function (url, result, key) {
console.log(url, result, key);
}, complete: function () {
alert('Everything has loaded in this test object!');
}});

yepnope({load: 'http://www.yandex.ru/dropcounters.js', callback: function (url, result, key) { // exception in this line
console.log(url, result, key);
}, complete: function () {
alert('Everything has loaded in this test object!');
}});
```

Exception:
"Could not convert JavaS...adElement.insertBefore]"
"NS_ERROR_XPC_BAD_CONVERT_JS"
(Firefox 10)

Error in yepnope-1.5.2.js at line 246

Your code:
```javascript
// If it's the first time, or we've already loaded it all the way through
if ( firstFlag || scriptCache[ url ] === 2 ) {
insBeforeObj.insertBefore( preloadElem, isGeckoLTE18 ? null : firstScript );

// If something fails, and onerror doesn't fire,
// continue after a timeout.
sTimeout( onload, timeout );
}
```

need (script already in cache and scriptCache[ url ] === 2):
```javascript
// If it's the first time, or we've already loaded it all the way through
if ( firstFlag || scriptCache[ url ] !== 2 ) {
insBeforeObj.insertBefore( preloadElem, isGeckoLTE18 ? null : firstScript );

// If something fails, and onerror doesn't fire,
// continue after a timeout.
sTimeout( onload, timeout );
}
```