How to debug dynamic js scripts in the browser (illustration): js scripts
Two days ago, I pulled the company's front-end code and found that the sources option of the developer tool did not list the js script I want to debug. Then I observed it, the script is dynamically introduced in the page. It may not be displayed because of this. However, if resumable debugging is not available, it is too inefficient to print logs, there are two ways to solve this problem:
1. Add // # sourceURL = xxxxxxxxx. js in the script and name it yourself. You can directly use the file name, for example:
Then open the page containing this js in the webpage, so that you can see it in the developer tool. You can break the breakpoint and debug it normally like normal JavaScript.
2. The second method is to use console. log ("let me debug it! ") Print the log, view the output in the browser console, and click the link below to jump into the dynamic script. The name is generally vmXXX, for example:
Summary
The above section describes how to debug dynamic js scripts in browsers. I hope it will be helpful to you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!