<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>BlackBerry Developer Blog &#187; Web Inspector</title>
	<atom:link href="http://devblog.blackberry.com/tag/web-inspector/feed/" rel="self" type="application/rss+xml" />
	<link>http://devblog.blackberry.com</link>
	<description></description>
	<lastBuildDate>Wed, 19 Jun 2013 18:00:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='devblog.blackberry.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/9ef0a66c09615fa946c4179662398878?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>BlackBerry Developer Blog &#187; Web Inspector</title>
		<link>http://devblog.blackberry.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://devblog.blackberry.com/osd.xml" title="BlackBerry Developer Blog" />
	<atom:link rel='hub' href='http://devblog.blackberry.com/?pushpress=hub'/>
		<item>
		<title>Using Web Inspector to get a 3000% performance boost</title>
		<link>http://devblog.blackberry.com/2012/07/web-inspector-performance-boost/</link>
		<comments>http://devblog.blackberry.com/2012/07/web-inspector-performance-boost/#comments</comments>
		<pubDate>Tue, 03 Jul 2012 15:35:11 +0000</pubDate>
		<dc:creator>Adam S.</dc:creator>
				<category><![CDATA[Case Studies & Success Stories]]></category>
		<category><![CDATA[Java Development]]></category>
		<category><![CDATA[blackberry playbook]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[Reader Mode]]></category>
		<category><![CDATA[Web Inspector]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=10035</guid>
		<description><![CDATA[A case study for using BlackBerry Web Inspector to help speed up developmental performance.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=10035&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><em>Here&#8217;s a guest post from Konrad to convince you of the powers of Web Inspector! &#8211; Adam S.</em></p>
<p><img src="http://rimdevblog.files.wordpress.com/2012/07/web-inspector-8.jpg?w=550&#038;h=322" alt="TITLE_IMAGE" title="TITLE_IMAGE" width="550" height="322" class="aligncenter size-full wp-image-10056" /></p>
<p>Have you ever used that cool button on your <a href="http://www.blackberry.com/playbook" target="_new">BlackBerry® PlayBook™</a> tablet Browser that looks like a book? It’s the icon in the top left that enables Reader Mode. This is a neat feature which takes away all the advertisements and extraneous features from the page and shows you a clean summary of the content. Today I wanted to tell you about how this feature came to be, how we optimized its performance, and how it would not have been possible without BlackBerry® Web Inspector.</p>
<p>Using some clever JavaScript®, we created a mechanism that extracted the page contents and stripped out unwanted HTML. The problem was that it took a really long time to parse a page and display the content &#8212; or so we thought. We knew that this would not be a good user experience and the page load time needed to be optimized, especially when compared to the better performance we observed for the same content running in a desktop browser.</p>
<p><span id="more-10035"></span></p>
<p>As I started my investigation, I wanted to look at the JavaScript to see how it worked so I could start to tweak it, and I thought to myself, &#8220;I should use Web Inspector to profile this.&#8221; I didn&#8217;t know it yet but this idea would save me lots of time and effort to get the feature working.</p>
<p>After adding some profiling information to the script, I discovered that most of the code was already relatively fast. However, after it had reloaded the page in a new WebView, it was doing its removal of the unwanted tags on the live DOM. This incurred a whole page request with sub-resources and content that we were going to be stripped out as soon as the page loaded.</p>
<p>Instead of incurring a page load, I did a deep copy of the DOM using <code>document.body.cloneNode(true)</code>, and then manipulated the HTML fragment off DOM. Finally I loaded the resulting HTML in a new WebView. The result of this change was an immediate gain in performance, reducing the amount of processing time from 45 seconds down to less than 5 seconds. But that wasn&#8217;t enough &#8212; no user should have to wait 5 seconds after hitting a button to see any results.</p>
<p>I then enlisted the help of a colleague, and we were able to optimize the script even further by making changes to our logging. If you log things in JavaScript inline via <code>console.log()</code>, they&#8217;re expensive. Instead, add your log message to a buffer and then print the results after the main processing is complete. The DOM was traversed several times during the algorithm&#8217;s run. We ended up using a TreeWalker instead of a for loop of <code>document.getElementsByTagName(“*”)</code> being used. With these simple changes and further optimizations to the script, we further reduced the page processing time from 5 seconds down to under 1.5, which in and of itself is still a gain of over 300%.</p>
<p>So in summary, we went from 45 seconds down to less than 1.5 seconds &#8212; an astonishing 3000% performance boost that we could not have done without Web Inspector running on device.</p>
<p><strong>Lessons:</strong></p>
<ol>
<li>Add logs to your scripts for performance profiling, but buffer them and don&#8217;t print to console right away.</li>
<li>Don&#8217;t reload the page when you don&#8217;t need to. If you want to modify the DOM, use HTML fragments.</li>
<li>Profile individual methods and try different things. You&#8217;d be surprised how changing one line can make all the difference.</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/10035/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/10035/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=10035&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/07/web-inspector-performance-boost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/16f032fc46b780f6d9fa38b24a7f8ff2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">adamstan1</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/07/web-inspector-8.jpg" medium="image">
			<media:title type="html">TITLE_IMAGE</media:title>
		</media:content>
	</item>
		<item>
		<title>Web Inspector from BlackBerry PlayBook OS 2.0 can improve performance, bug fixing and experience building</title>
		<link>http://devblog.blackberry.com/2012/02/web-inspector-playbook/</link>
		<comments>http://devblog.blackberry.com/2012/02/web-inspector-playbook/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 20:03:13 +0000</pubDate>
		<dc:creator>Adam S.</dc:creator>
				<category><![CDATA[Java Development]]></category>
		<category><![CDATA[Native SDK Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[blackberry playbook]]></category>
		<category><![CDATA[BlackBerry PlayBook development]]></category>
		<category><![CDATA[BlackBerry PlayBook OS 2.0]]></category>
		<category><![CDATA[blackberry webworks]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web Inspector]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=8583</guid>
		<description><![CDATA[BlackBerry developers can use the Web Inspector utility to help to debug and profile web application content running on a BlackBerry PlayBook tablet.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=8583&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>BlackBerry® developers can use the Web Inspector utility to help to debug and profile web application content running on a BlackBerry® PlayBook™ tablet. I discussed this earlier in a blog post entitled “<a href="http://devblog.blackberry.com/2011/06/debugging-blackberry-web-apps/" target="_new">Debugging BlackBerry web applications using Web Inspector</a>,” and BlackBerry remains the only mobile development platform in the market with this feature. This powerful debugging tool can be used to test and troubleshoot HTML5 content, running either in the browser or within an application created using the <a href="https://bdsc.webapps.blackberry.com/html5/" target="_new">BlackBerry® WebWorks™ SDK</a>. Instructions about <a href="http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/How-to-debug-BlackBerry-web-applications-using-Web-Inspector/ta-p/1207155" target="_new">how to debug BlackBerry web applications using Web Inspector</a> can be found in developer support documentation.</p>
<p>The <a href="http://devblog.blackberry.com/2012/02/build-web-apps-playbook/" target="_new">BlackBerry® PlayBook™ OS 2.0 software upgrade</a> provided major enhancements to the web developer platform, and I wanted to highlight some of the key improvements to Web Inspector that are now available in OS 2.0 as well. These enhancements can make it easier for developers to fix bugs, improve performance and create positive experiences for their users.</p>
<h3><strong>Quick access settings menu</strong></h3>
<p>A settings panel is now available to help developers configure how information is presented within Web Inspector. Developers can define default formats for colors, text indentation and word wrap behavior.</p>
<p><img class="aligncenter size-full wp-image-8590" title="" src="http://rimdevblog.files.wordpress.com/2012/02/web-inspector-1.jpg?w=500&#038;h=406" alt="" width="500" height="406" /></p>
<p><span id="more-8583"></span></p>
<h3><strong>Network panel</strong></h3>
<p>The new networking panel displays helpful information about HTTP request and responses made by your application. This includes network traffic logging about documents, style sheets, images, scripts, XmlHttpRequest, fonts and even web sockets.</p>
<p>Click on any resource displayed on the left side panel to view its request and response HTTP headers as well as a preview of the actual resource.</p>
<p><img class="aligncenter size-full wp-image-8589" title="" src="http://rimdevblog.files.wordpress.com/2012/02/web-inspector-2.jpg?w=500&#038;h=255" alt="" width="500" height="255" /></p>
<h3><strong>Context Menu</strong></h3>
<p>Right-clicking on any panel in Web Inspector will now display a new context menu. This menu contains items that are relevant to the current window. For example, within the “Elements” panel developers can edit or copy selected HTML elements, while in the Network panel, developers can copy link addresses as well as HTTP request and response headers.</p>
<p><img class="aligncenter size-full wp-image-8588" title="" src="http://rimdevblog.files.wordpress.com/2012/02/web-inspector-3.jpg?w=500&#038;h=279" alt="" width="500" height="279" /></p>
<p><strong>Note:</strong> Access to the system clipboard is restricted by JavaScript®, so in order to implement this copy feature, Web Inspector will instead open a new tab or window in your browser and display the selected information in plain text. If you have popup blocking enabled, you may not see this new tab or window.</p>
<h3><strong>Console window auto-complete</strong></h3>
<p>Another great improvement is that Web Inspector has been designed to respond to what you type in the console window. Often the console is used to make dynamic calls to JavaScript loaded on the page. This can be a helpful practice for checking variable values or running debug code.<br />
To see this in action, start typing some JavaScript from within the console window, such as the example shown in the following screenshot. After each period, you should be prompted with a drop-down list of available method or property names for the current JavaScript object you have provided.</p>
<p><img class="aligncenter size-full wp-image-8587" title="" src="http://rimdevblog.files.wordpress.com/2012/02/web-inspector-4.jpg?w=500&#038;h=136" alt="" width="500" height="136" /></p>
<h3><strong>Custom User Agent</strong></h3>
<p>Web Inspector can now be used to change the value of the user agent header. This header is often used by web servers to detect which browser is currently being used to access a web page, and provide custom content targeted to that browser. Open up the settings window and select the “Override User Agent” checkbox. You can then select from a list of default user agent values, or provide your own.</p>
<p>See the “<a href="http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/How-to-detect-the-BlackBerry-Browser/ta-p/559862" target="_new">How to detect the BlackBerry Browser</a>” developer article for more information about the format of the user agent header on the BlackBerry web platform.</p>
<p><img class="aligncenter size-full wp-image-8586" title="" src="http://rimdevblog.files.wordpress.com/2012/02/web-inspector-5.jpg?w=450&#038;h=146" alt="" width="450" height="146" /></p>
<h3><strong>JavaScript “pretty print”</strong></h3>
<p>Minifying JavaScript is an excellent way of improving web page performance by reducing unneeded bandwidth. However, it can become very difficult to debug minified JavaScript as finding the right place to set breakpoints can be challenging.</p>
<p>When JavaScript is minified, all whitespace and comments are removed. This often results in an entire library being displayed as a single line of code.</p>
<p><img class="aligncenter size-full wp-image-8585" title="" src="http://rimdevblog.files.wordpress.com/2012/02/web-inspector-6.jpg?w=450&#038;h=210" alt="" width="450" height="210" /></p>
<p>Fortunately for BlackBerry developers, Web Inspector now provides a “Pretty print” feature, which can be found at the bottom of the status bar in the Scripts panel. When clicked, it will automatically re-format all JavaScript using appropriate indentation and whitespace.</p>
<p><img class="aligncenter size-full wp-image-8584" title="" src="http://rimdevblog.files.wordpress.com/2012/02/web-inspector-7.jpg?w=450&#038;h=388" alt="" width="450" height="388" /></p>
<p>Don’t forget to use Web Inspector as part of developing and testing your HTML5 and BlackBerry WebWorks applications. It can save you a lot of time and frustration in tracking down a bug, or finding ways to optimize your web content.</p>
<p>Try it out for yourself, and <a href="http://twitter.com/BlackBerryDev" target="_new">let us know</a> how it helps with your BlackBerry development.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/8583/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/8583/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=8583&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/02/web-inspector-playbook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/16f032fc46b780f6d9fa38b24a7f8ff2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">adamstan1</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/02/web-inspector-1.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/02/web-inspector-2.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/02/web-inspector-3.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/02/web-inspector-4.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/02/web-inspector-5.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/02/web-inspector-6.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/02/web-inspector-7.jpg" medium="image" />
	</item>
	</channel>
</rss>
