Why doesn't mobile Safari have a JavaScript console?

My question is fairly simple, seeing as iPod has full support for executing JavaScript (proven my bookmarklets (See below) why doesn't it have a "dev tools" option, or at least a JS console? Is there a specific reason for this feature not to exist standalone mobile?

Or am I blind and that it's actually there?*

As for the bookmarklets it's fairly simple, navigate to blank.org (or any site really), bookmark it, edit the bookmark and replace it with something like this;

javascript:void(document.bgColor=prompt('Color?%20Hex%20or%20name%20will%20do.%20May%20I%20suggest%20red?','red'))

Or any JS code after javascript:

Not my code, you can find code where I got this from at http://code.tutsplus.com/tutorials/create-bookmarklets-the-right-way--net-18154*


Solution 1:

Well, we can only speculate as to why Apple doesn't include a JavaScript console but we can make some assumptions.

  • Screen real-estate is limited on a mobile device, and it would be cumbersome to use (imagine trying to code with an iPhone keyboard).

  • Mobile devices are, in general, not intended for web development. Apple wants to keep their UI/UX as streamlined as possible. Including a feature which, in Apple's opinion, is unnecessary, works against this goal.

Solution 2:

You mention "standalone" so you may be aware of this already and have discounted it, but I thought I'd mention it anyway just in case.

It is possible to use the development tools within Safari on a Mac (including the JavaScript console) to diagnose faults and develop sites for iOS devices.

  • Connect your iPhone or iPad to your Mac using a USB cable.
  • On your iOS device, go into the Settings, select Safari then Advanced. You should see a switch for "Web Inspector". Switch it on.
  • On your Mac, go into the Preferences within Safari and on the Advanced tab you should see a tick box for "Show Develop menu in menu bar". Tick it.
  • Now if you open the Develop menu within Safari on your Mac you should now see a submenu for your iOS device listing the available "inspectable applications". I've only seen Safari on this list, but I assume other applications that use UIWebViews are inspectable too.

Arguably more useful than having web development tools built into the devices themselves.