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

1
  • 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 Commented Dec 18, 2019 at 10:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.