Subj : dynamic script loading crash To : netscape.public.mozilla.jseng From : Scott Shattuck Date : Tue Jan 21 2003 08:47 pm Hi all, I'm running into a crashing error trying to dynamically load script files. I've already sent talkback data about this since it crashes the browser with absolute consistency all the way up through 1.3A. I'm still trying to nail down a decent test case without having to include my actual source (it's way too big) but was hoping I might get a little help/insight from the group. Here's the scenario: An XML file containing configuration data is read by a script and used as source information to drive a loop which creates script elements and sets their src attributes, thereby loading the script source code. The onload handler triggers the next script load call. When run from a file:/// url this operation works perfectly and has no apparent limitations on the number of scripts etc. When run from an http:// url this will crash the browser every time once either: ~250 scripts have loaded (our library contains over 400 classes) OR you Reload the script. Again, neither of these cause file:// launches any problems. Any ideas what's going on here? The load code is _identical_ whether the url is file:// or http:// prefixed. It's basically: el = document.createElement('script'); el.onload = function() { // create closure around callback function parameter if (typeof(aCallback) == 'function') { aCallback(el); }; }; try { el.setAttribute('src', targetUrl); document.getElementsByTagName('head')[0].appendChild(el); } catch (e) { stderr('Requested file ' + targetUrl + ' does not exist'); return null; }; I've also tried it using the following (where our $$fileLoad function uses XMLHTTPRequest to get the script source text): el = document.createElement('script'); src = $$fileLoad(targetUrl, RAW); if (src == null) { stderr('Requested file ' + targetUrl + ' source not available'); return null; }; try { tn = document.createTextNode(src); el.appendChild(tn); document.getElementsByTagName('head')[0].appendChild(el); } catch (e) { stderr('Error processing ' + targetUrl + ' source'); return null; }; If it didn't work with file url's I'd be suspicious of recursion, or creating too many script nodes, or similar issues. But it's very specific to http. If you have any alternative ways to consider for loading script source into the current context when running over HTTP I'd appreciate it. This is a showstopper right now for me and is holding up a major product release. Thanks in advance for hints or help! ss Scott Shattuck TIBET Project Architect .