How to debug JavaScript code with mobile browsers

BrowserMobileFirebug

Browser Problem Overview


I know about firebug and the developer tools for the major modern desktop browsers, but I can't find any way of debugging JavaScript code on mobile browsers.

What are some high level techniques I can use to debug code on mobile browsers?

Browser Solutions


Solution 1 - Browser

Android devices can be put into developer mode by going through settings>Phone status then tapping on "Build number" 7 times. This allows you to do a bunch of things (see step 5) including USB debugging. (Some devices might have Build number under Software Info)

To activate USB debugging, look in Settings for the newly appeared "{ } Developer Options", open this and switch on USB debugging. Connect your device using a direct USB connection.

In Chrome on your desktop, in the usual developer tools panel used for debugging, look in the menu for more tools>remote devices. With Discover USB devices selected, you should now see your mobile device on the side.

Select it to see a list of all the chrome tabs you have open and the ability to enter URLs directly.

Selecting one of the links will open up a new window with a mirror of your device screen on the left and all the familiar chrome debug tools on the right. You can still control your device directly or use the mouse on the mirrored screen. It even rotates.

full details on remote debugging from google and how to enable developer mode (link as above) from askvg.com

Solution 2 - Browser

Solution 3 - Browser

You can debug on Safari Mobile with any iPhone/iPad. In Developer menu you can find your device and you can then debug your code with inspector.

If you have an Android Device instead, you can debug on Chrome Desktop (remember to active the debug mode) with chrome://inspect

Solution 4 - Browser

On the IPhone you can go into settings>Safari>advanced and turn web inspector on

Solution 5 - Browser

Sometimes I get bugs reported by customers that are not reproducible every time or in our testing. For such cases I recommend Lucky Orange. It records the user activity and also has the option to record console messages.

PS - I'm not an affiliate, I use them for my own projects and like it.

Solution 6 - Browser

You can use Chrome remote debugger. Check here.

If you are not using Mobile Chrome in that case you can use OutFront JS. It helps to log warnings, errors, and logs to DOM.

Solution 7 - Browser

Another solution for basic debugging (which many times is all is needed), is having a console polyfill on mobile without the need to plug into USB on desktop.

mobileConsole is such a console polyfill.

Hope it helps someone, I found it useful.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionchnxsterView Question on Stackoverflow
Solution 1 - BrowserfrankiView Answer on Stackoverflow
Solution 2 - BrowserHermann SchwarzView Answer on Stackoverflow
Solution 3 - BrowserSalvatore CozzuboView Answer on Stackoverflow
Solution 4 - BrowserThe DibMasterView Answer on Stackoverflow
Solution 5 - BrowserWhipView Answer on Stackoverflow
Solution 6 - BrowserGauravView Answer on Stackoverflow
Solution 7 - BrowserNikos M.View Answer on Stackoverflow