<?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/"
	>

<channel>
	<title>Reality Distortion: Macs, Mac OS X, and Apple stuff &#187; Uncategorized</title>
	<atom:link href="http://mac.elated.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://mac.elated.com</link>
	<description>A blog about Macs and that</description>
	<lastBuildDate>Mon, 19 Jul 2010 00:09:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Web developer features in Safari</title>
		<link>http://mac.elated.com/2008/05/22/web-developer-features-in-safari/</link>
		<comments>http://mac.elated.com/2008/05/22/web-developer-features-in-safari/#comments</comments>
		<pubDate>Thu, 22 May 2008 10:20:19 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Mac tips & tricks]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mac.elated.com/?p=142</guid>
		<description><![CDATA[
If you&#8217;re a Web coder, Safari 3 offers some really nice debugging features &#8211; if you know where to look for them. First, you need to turn on Safari&#8217;s Develop menu (hidden by default). To do this, choose Safari &#62; Preferences, then in the Advanced tab check the Show Develop menu in menu bar option. [...]]]></description>
			<content:encoded><![CDATA[<pre><img class="alignleft size-full wp-image-248" style="margin: 0 10px 0 0;" title="safari-icon-with-wrench" src="http://mac.elated.com/wp-content/uploads/safari-icon-with-wrench.jpg" alt="" width="100" height="93" /></pre>
<p>If you&#8217;re a Web coder, <strong>Safari 3</strong> offers some really nice debugging features &#8211; if you know where to look for them. First, you need to turn on Safari&#8217;s <strong>Develop</strong> menu (hidden by default). To do this, choose <strong>Safari &gt; Preferences</strong>, then in the <strong>Advanced</strong> tab check the <strong>Show Develop menu in menu bar</strong> option. You&#8217;ll see the new menu appear to the right of the <strong>Bookmarks</strong> menu in the menu bar.</p>
<p><a href="http://mac.elated.com/wp-content/uploads/safari-develop-menu.png"><img class="alignright size-thumbnail wp-image-250" title="safari-develop-menu" src="http://mac.elated.com/wp-content/uploads/safari-develop-menu-150x150.png" alt="" width="150" height="150" /></a>The first option, <strong>Open Page With</strong>, lets you open the current page in any other installed browser &#8211; handy for cross-browser testing. The second, <strong>User Agent</strong>, tells Safari to masquerade as another browser when viewing websites. Safari still renders pages as Safari, but sends another user agent string to the Web server. This can be useful if you&#8217;re testing browser detection code, for example.</p>
<h4>Call in the Inspector</h4>
<p>The fun really starts with the next option, <strong>Show Web Inspector</strong>. The Web Inspector window is reminiscent of the <a href="http://www.getfirebug.com/">Firebug</a> Firefox add-on, and shows you the syntax-highlighted markup (or, by clicking the button in the toolbar, the DOM tree) of the current page, the contents of any linked style sheets, the images used in the page (with info), the source code of any JavaScript in the page, and info on any other page elements it finds.</p>
<p><a href="http://mac.elated.com/wp-content/uploads/safari-web-inspector.png"><img class="alignnone size-medium wp-image-251" title="safari-web-inspector" src="http://mac.elated.com/wp-content/uploads/safari-web-inspector-300x208.png" alt="" width="300" height="208" /></a></p>
<p>Click the <strong>Console</strong> option at the bottom left of the window, and you can see JavaScript errors and other messages; click on an error to jump straight to the JavaScript line that caused it (nice). You can also type your own JavaScript commands into the single-line box at the bottom of the console window and see the results appear above &#8211; great for finding out the current state of variables and so on.<span id="more-142"></span></p>
<p>Another nice touch:  You can <strong>log your own JavaScript debugging messages</strong> to the Console; much more convenient than using <tt style="font-size: 1.4em;">alert()</tt>. To do this, use <tt style="font-size: 1.4em;">window.console.log()</tt>:</p>
<pre style="font-size: 1.4em;">&lt;script type="text/javascript"&gt;
  window.console.log ( "Hello, world!" );
&lt;/script&gt;</pre>
<p>Deeply cool, though, is the <strong>Network</strong> option below Console. This reveals a <strong>timeline</strong> that shows you how long each part of the current Web page took to load over the network. The bars are <strong>colour-coded</strong> by media type: green for style sheets, purple for images, and so on. This is a really great way to see how long your site is taking to load, and what the bottlenecks are. I&#8217;ve used a few such network profiling tools in the past, but none are as readily accessible (and as pretty) as this one.</p>
<p><a href="http://mac.elated.com/wp-content/uploads/safari-web-inspector-network.png"><img class="alignnone size-medium wp-image-252" title="safari-web-inspector-network" src="http://mac.elated.com/wp-content/uploads/safari-web-inspector-network-300x208.png" alt="" width="300" height="208" /></a></p>
<h4>The geeky joy continues</h4>
<p>Moving further down the Develop menu, we have the <strong>Snippet Editor</strong>. Enter HTML and CSS directly into the top pane of the Snippet Editor window, and the rendered results appear in the bottom pane. This can be useful for testing small snippets of markup without having to edit a Web page, but in practice I find it&#8217;s more useful to just go ahead and test within the page proper.</p>
<p>The <strong>final six options</strong> let you disable various Safari features to aid with debugging. They work like this:</p>
<ul>
<li><strong>Disable Caches: </strong>Temporarily turns off caching, forcing Safari to fetch Web pages, images and other resources from the net each time they&#8217;re needed. Great for making sure you&#8217;re looking at the most recent version on your server.</li>
<li><strong>Disable Images: </strong>Replaces all images in the page with the contents of their &#8216;alt&#8217; attributes. Good for checking you&#8217;ve included &#8216;alt&#8217; attributes for all your images (as every Web developer should!).</li>
<li><strong>Disable Styles: </strong>Turns off all CSS styles, displaying the markup without any CSS applied. Useful for making sure your page makes sense to non-CSS user agents, such as text browsers, screen readers and, perhaps most importantly, search engines.</li>
<li><strong>Disable JavaScript: </strong>This is exactly the opposite of the <strong>Safari &gt; Preferences &gt; Security &gt; Enable JavaScript</strong> option. Use it for those times when you want to test how a site behaves with JavaScript turned off.</li>
<li><strong>Disable Runaway JavaScript Timer: </strong>Safari features a built-in failsafe timer for those times when your JavaScript runs very slowly or gets itself in an infinite loop. (We&#8217;ve all been there.) However it can get in the way occasionally when you&#8217;re running certain types of scripts. Turn it off with this option.</li>
<li><strong>Disable Site-specific Hacks: </strong>Yucky, but true &#8211; Safari apparently contains hacks and workarounds for certain types of Web pages (Apple purists avert your eyes). You can disable such hacks with this option. (Exactly what these hacks are is a mystery.)</li>
</ul>
<p>The <strong>Develop</strong> menu in Safari 3 is a powerful beast, and it&#8217;s a great way to debug Web pages. I find myself using it quite a bit these days (as well as Firebug in Firefox).</p>
<p>By the way, if you&#8217;re after more <strong>general info</strong> on developing Web pages with Safari, the Apple developer site has a decent <a href="http://developer.apple.com/internet/safari/faq.html">Safari Developer FAQ</a>.</p>
<img src="http://mac.elated.com/?ak_action=api_record_view&id=142&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://mac.elated.com/2008/05/22/web-developer-features-in-safari/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
