This article is a mirror article of machine translation, please click here to jump to the original article.

View: 16001|Reply: 1

[JavaScript] 5 debugging tips for JS debugging

[Copy link]
Posted on 6/13/2017 1:11:32 PM | | | |
1. debugger;I've said before that you can add a debugger sentence to your Javascrip{filter}t code; to create a breakpoint effect by hand.
Need a breakpoint with conditions? You just need to surround it with an if statement:


But remember to cut them before the program is released.
2. Set the breakpoint to trigger when the DOM node changes

Sometimes you will find that the DOM is out of your control and will undergo strange changes on its own, making it difficult to get to the root of the problem.
There is a super useful feature in Google Chrome's development tools that can deal with this situation, called "Break on...", you can right-click on the DOM node and you can see this menu item.
The trigger condition for a breakpoint can be set so that the node is deleted, the node's properties change, or one of its subnodes changes.


3. Ajax breakpoints

XHR breakpoints, or Ajax breakpoints, like their name, allow us to set a breakpoint that triggers the Ajax call of a feature when it occurs.
This is very effective when you are debugging a web application over a network.


4. Mobile device simulation environment

Google Chrome has some very interesting tools to simulate mobile devices that help us debug how the program works on the mobile device.
To find it, press F12, bring up the developer tools, then press the ESC key (the current tab cannot be Console), and you will see the second level of debugging window appear, in the Emulation tab with various emulation devices to choose from.
Of course, this will not be a real iPhone, but just simulate the dimensions of the iPhone, touch events and browser User Agent values.


5. Improve your website with Audits

YSlow is a great tool. There is a very similar tool in Google Chrome's developer tools called Audits.
It quickly audits your website and gives you very practical and effective suggestions and ways to optimize your website.






Previous:Taobao through train batch setting of selected groups [software]
Next:js object method, class method, and prototype method are differentiated
Posted on 6/13/2017 3:24:17 PM |
Useful, not bad
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com