0

i am currently working on a simple javascript module system (similar to the node.js module system or requireJS).

To load javascript files that are required for a module i use the mootools request object:

var request = new Request({
    url: <url to javascript file>,
    method: 'get',
    onSuccess: function(jsFileContent) {
        var func = new Function(jsFileContent);
        var result = func();
        // ...
    }
}).send();

The code works fine so far. My problem is that javascript files that are loaded this way don't show up in Firebug. So debugging of these files becomes hard because Firebug features like breakpoints cannot be used.

Is there any way to make this work with Firebug? Or is there any other way to load other javascript files from javascript that work fine with Firebug?

Thanks

micha
  • 47,774
  • 16
  • 73
  • 80
  • 1
    Pick your dup: http://stackoverflow.com/questions/4716957/debugging-javascript-code-that-comes-as-part-of-ajax-response or http://stackoverflow.com/questions/1705952/is-possible-to-debug-dynamic-loading-javascript-by-some-debugger-like-webkit-fi or http://stackoverflow.com/questions/7188245/firebug-debugging-script-loaded-dynamically or http://stackoverflow.com/questions/858779/making-firebug-break-inside-dynamically-loaded-javascript – Matt Ball Apr 21 '12 at 16:48
  • Thanks, i didn't saw these.. :-( – micha Apr 27 '12 at 16:44

1 Answers1

0

i think the only way to easily do that is adding a script tag... i suggest to write a wrapper that checks for a global debug flag... if debug flag is on it inserts a script via script tag if off it inserts it via ajax

Tobias Krogh
  • 3,768
  • 20
  • 14