How the Chrome browser breakpoints debug asynchronous loading Js_javascript Tips

Source: Internet
Author: User
Tags getscript

Objective

In our daily development, often using the powerful Chrome console sources code breakpoint debugging, but by $.getScript the way the asynchronous loading JS in the sources inside is not found, that how debug breakpoint debugging? Let's take a look together.

This is the example diagram we used to debug with sources breakpoints:

As we can see in the index.js, we $.getScript introduce test.js to see how it behaves:

We see in network that Test.js has been introduced successfully, but it belongs to the XHR class request, so that we cannot find it in sources.

Unsurprisingly, sources found no traces of test.js! The climax comes, that also how to carry on the breakpoint debugging???

I know two programs, first come to the simplest:

Plan One: in the test.js code of the head or tail plus //@ sourceURL=test.js , and then (no domain) find it in the inside to debug, see the results:

Scenario Two: $.getScript replace this asynchronous approach with creating a script label to load synchronously, directly above:

Summarize

Console breakpoint on our code check, function detection, data viewing and so on demand is too useful, we try to use breakpoints to replace that annoying Console.log bar, the above is the entire content of this article, I hope that the study and work can help, if you have questions you can message exchange.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.