1

I have a few dynamically loaded JS scripts that I want to be able to debug in chrome DevTools. I have read that I should be able to achieve this by appending //#sourceURL=someFile.js To the source I will be using eval on. This is what I currently have:

var loadDynamic = function(filename){
    var request = new XMLHttpRequest();
    request.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            eval(this.responseText + "\r\n" + "//#sourceURL="+filename);
        }
    };
    request.open("GET", filename, false);
    request.send();
}
loadDynamic("someFile.js");

I am getting no errors in the console log and the source is not being added to the source tree. However the evaluated code is definitely loaded and executed correctly. It is just the #sourceURL that isn't getting picked up.

Am I using this correctly? Thanks

codetemplar
  • 671
  • 6
  • 19
  • I think the browser is comparing the files before matching the source tree. Otherwise on edit you would append the additional characters to your original file – Tires Dec 18 '19 at 10:32

0 Answers0