<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:series="http://organizeseries.com/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"> <channel><title>SitePoint</title> <link>http://www.sitepoint.com</link> <description>Learn CSS | HTML5 | JavaScript | Wordpress | Tutorials-Web Development | Reference | Books and More</description> <lastBuildDate>Tue, 21 May 2013 13:30:03 +0000</lastBuildDate> <language>en-US</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.5.1</generator> <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/SitepointFeed" /><feedburner:info uri="sitepointfeed" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><title>Be Convincing and Win More Clients</title><link>http://feedproxy.google.com/~r/SitepointFeed/~3/4JUqBjMGtKI/</link> <comments>http://www.sitepoint.com/be-convincing-and-win-more-clients/#comments</comments> <pubDate>Tue, 21 May 2013 13:30:03 +0000</pubDate> <dc:creator>John Tabita</dc:creator> <category><![CDATA[Business]]></category> <category><![CDATA[Freelancing]]></category> <category><![CDATA[General business]]></category> <category><![CDATA[Marketing]]></category> <category><![CDATA[clients]]></category> <category><![CDATA[freelance]]></category> <category><![CDATA[freelancing]]></category> <category><![CDATA[sales]]></category> <category><![CDATA[selling]]></category> <category><![CDATA[selling your services]]></category> <category><![CDATA[small business]]></category> <guid isPermaLink="false">http://www.sitepoint.com/?p=66329</guid> <description><![CDATA[Are you convincing enough?]]></description> <content:encoded><![CDATA[<p></p><p>A number of years ago, I applied for a sales position. It was the first time I’d done so. As part of the application process, I had to complete an online self- assessment. Somewhere around the eighth question, it became apparent that the sole purpose of this “assessment” was to assess whether I was an extrovert or not. Questions like “How many extra-curricular activities or clubs did you belong to in high school?” made it clear that the company believed extroverts make better sales people.</p><p>If only it were that simple. According to research conducted by RAIN Group, you to win or lose at sales because of your behavior, not your personality bent. Their study revealed that top sales people engage in three specific selling behaviors that set them apart:</p><ol><li>They <em>connect</em></li><li>They <em>convince</em></li><li>They <em>collaborate</em></li></ol><p>The people at RAIN describe these as “three levels” that ought to be applied as a combination, not separately or sequentially—but caution that those who stop at Level 1 do not find themselves in the winner’s circle nearly as often.</p><p>This poses a challenge to introverted web designers and programmers faced with the need to “sell your services.” While we do well connecting and collaborating, we’re not so comfortable with <em>convincing</em>. In fact, I’d say we’re so uncomfortable with it that we take collaborating much too far, by <a
title="Stop Giving Away So Much Free Information!" href="http://www.sitepoint.com/stop-giving-away-so-much-free-information/" target="_blank">giving away too much free information</a> and <a
title="Proposals are for Wimps" href="http://www.sitepoint.com/proposals-are-for-wimps/" target="_blank">writing proposals</a> for which the client didn’t ask—hoping that these will do the convincing for us.</p><p>Instead, we’re left wondering why the client went elsewhere.</p><p>There’s no doubt that to be an effective sales person, you must possess certain social skills. In order to win, you must be able to convince the prospect that:</p><ol><li>You can achieve the results he’s after</li><li>The return on investment is worth it</li><li>The risk is acceptable</li><li>You are the best choice among the available options</li></ol><p>According to the <a
title="What Sales Winners Do Differently" href="http://www.raintoday.com/library/on-demand-events/sales-winners-webinar/" target="_blank">RAIN Group report</a>, even seasoned sales people are resistant to using maximum persuasion, yet …</p><blockquote><p>… in our research, the winners convinced, and convinced with gusto.</p></blockquote><p>Are you focusing too much effort on collaborating and not enough on convincing? It’s time to “go for the gusto” and start convincing.</p><p
style="text-align: right"><em><a
href="http://www.sxc.hu/profile/marczini" target="_blank">Image credit</a></em></p><div
class='after-content-widget-1'><div
id="sitepointcontextualcontentmanagerwidget-5" class="widget widget_sitepointcontextualcontentmanagerwidget"><style>#targettedEOF { width: 99%; font-family: "Open Sans", Helvetica, Arial, sans-serif; border-radius: 4px; border: 1px dotted #47B4DC; }
#targettedEOF .targettedEOFcol { float: left; padding: 20px; }
#targettedEOF .targettedEOFbtn { clear: both; padding: 0; }
#targettedEOF h2 { margin-top: 10px; }
#targettedEOF .sptolbCTA { border: 0 none; border-bottom: 2px solid #85bb41; background-color: #91c352; color: white; margin: 0; padding: 1em 1em; border-radius: 4px; vertical-align: middle; text-align: center; font-weight: 700; font-size: 17px; display: inline-block; line-height: 0; text-shadow: -1px -1px 1px rgba(0,0,0,0.2); cursor: pointer; text-decoration: none;
}
#targettedEOF .sptolbCTA:hover { color: white; }
#targettedEOF .targettedEOFbtn p { padding: 0; margin: 0; }
.cat_javascript #targettedEOF h2, .cat_cloudspring #targettedEOF h2 { font-size: 1.267em; line-height: 1.158em; margin: 1.737em 0 0.579em 0; font-weight: bold; color: #0071D8; }
.cat_javascript #targettedEOF, .cat_cloudspring #targettedEOF { font-size: 1.5em; line-height: 1.467em; width: 100%; }
.cat_javascript #targettedEOF ul, .cat_cloudspring #targettedEOF ul { list-style: square; margin: 0 0 1.467em 1.467em; }</style><div
id="targettedEOF"><div
class="targettedEOFcol"> <a
href="https://learnable.com/books/jsjavascript1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=UltimateJavaScriptBundle"><img
src="https://learnable-images.s3.amazonaws.com/books/responsive1_medium.jpg" width="145"></a></div><div
class="targettedEOFcol"><h2>Learn Responsive Web Design</h2><ul><li>SitePoint's ebook: <a
href="https://learnable.com/books/responsive1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Jump Start Responsive Web Design</a></li><li><a
href="https://learnable.com/courses/responsive-web-design-key-concepts-2759?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Responsive Web Design: Key Concepts</a> online course</li><li>Unlimited access to <a
href="https://learnable.com/topics/front-end?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign"> SitePoint Premium Content</a></li></ul><p><a
class="sptolbCTA" href="https://learnable.com/?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign#pricing">Join Learnable $29</a> <span><strong>Includes all SitePoint books</strong></span></div><div
class="targettedEOFbtn"></div></div><div
class="dfp-ad show-desktop"><div
id="div-gpt-ad-1340873946991-4" style="width: 728px; height: 90px;"> <script type="text/javascript">googletag.cmd.push(function() { googletag.display("div-gpt-ad-1340873946991-4"); });</script> </div></div></div></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=4JUqBjMGtKI:hdL6fpYKfZ8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=4JUqBjMGtKI:hdL6fpYKfZ8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=4JUqBjMGtKI:hdL6fpYKfZ8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?i=4JUqBjMGtKI:hdL6fpYKfZ8:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SitepointFeed/~4/4JUqBjMGtKI" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/be-convincing-and-win-more-clients/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://www.sitepoint.com/be-convincing-and-win-more-clients/</feedburner:origLink></item> <item><title>Even Better CSS3 Toggle Switches!</title><link>http://feedproxy.google.com/~r/SitepointFeed/~3/K86-tjxPbSo/</link> <comments>http://www.sitepoint.com/better-css3-toggle-switches/#comments</comments> <pubDate>Mon, 20 May 2013 11:14:16 +0000</pubDate> <dc:creator>Craig Buckler</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[CSS3]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[HTML5]]></category> <category><![CDATA[Responsive Web Design]]></category> <category><![CDATA[UX]]></category> <category><![CDATA[form]]></category> <category><![CDATA[HTML5 Dev Center]]></category> <category><![CDATA[HTML5 Tutorials & Articles]]></category> <guid isPermaLink="false">http://www.sitepoint.com/?p=66145</guid> <description><![CDATA[Did you like Craig's CSS toggle switches but wanted a little more accessibility or to use them on radio buttons? No problem: he's back with a solution...]]></description> <content:encoded><![CDATA[<p></p><p>Many of you liked my previous article, <a
href="/css3-toggle-switch/">How to Create a Toggle Switch in CSS3</a>. However, a few issues were raised in the comments and on <a
href="http://twitter.com/craigbuckler">Twitter</a>&hellip;</p><ol><li>How do you apply toggles to radio buttons?</li><li>Can accessibility be improved?</li><li>Why doesn&#8217;t it work on older mobile Webkit browsers?</li></ol><p>I&#8217;ve made some improvements, so please <a
href="http://cssdeck.com/labs/full/better-css-toggle-switches"><strong>view the demonstration page</strong></a> and <a
href="http://cssdeck.com/labs/full/better-css-toggle-switches">the HTML/CSS code&hellip;</a></p><h2>Radio Button Support</h2><p>An easy one to start with. Radio buttons function almost identically to checkboxes so we can simply apply a class of &#8220;switch&#8221; to every input to make it work, e.g.</p><pre><code>&lt;div&gt;
&lt;input type=&quot;radio&quot; id=&quot;radio1&quot; name=&quot;radio&quot; class=&quot;switch&quot; /&gt;
&lt;label for=&quot;radio1&quot;&gt;first radio button&lt;/label&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;input type=&quot;radio&quot; id=&quot;radio2&quot; name=&quot;radio&quot; class=&quot;switch&quot; checked=&quot;checked&quot; /&gt;
&lt;label for=&quot;radio2&quot;&gt;second radio button&lt;/label&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;input type=&quot;radio&quot; id=&quot;radio3&quot; name=&quot;radio&quot; class=&quot;switch&quot; /&gt;
&lt;label for=&quot;radio3&quot;&gt;third radio button&lt;/label&gt;
&lt;/div&gt;
</code></pre><p>It&#8217;s very satisfying to see two switches alter position at the same time!<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><h2>Amended Accessibility</h2><p>Richard from <a
href="http://accessibleweb.eu/">Accessible Web Design</a> raised a couple of concerns. First, the switches change between red and green; if you&#8217;re color-blind, it would not be easy to determine whether the switch was on or off. To remedy the problem, I&#8217;ve added a check and cross character to the background:</p><p><img
src="http://blogs.sitepointstatic.com/images/tech/826-better-css3-toggle-switches-onoff.png" width="197" height="64" alt="toggle characters" class="center" /></p><p>No additional element were required &#8212; I simply used a cross character instead of a space and positioned it on the right of the background using <code>text-indent</code>:</p><pre><code>input.switch:empty ~ label:before
{
	content: '\2718';
	text-indent: 2.4em;
	color: #900;
}</code></pre><p>When the checkbox/radio is checked, it changes to a check character and is moved to the left of the background:</p><pre><code>input.switch:checked ~ label:before
{
  content: '\2714';
  text-indent: 0.5em;
  color: #6f6;
}</code></pre><p><strong>Cross-Browser CSS3 Animation</strong><br
/> Originally, I placed the check/cross character on the white switch itself. This is complex for the browser since it must create a transition between two different characters. Firefox worked, but Chrome and IE10 take an easier route: <em>they abandon the animation completely!</em> It appears that Webkit and Trident will not permit animation on a pseudo element if its content is changing &#8212; even if you explicitly state that only the margin or color should be animated.</p><p>To address the issue, I applied the check/cross to the :before toggle background and removed its transition effect (the color will not smoothly change, but it&#8217;s hardly noticeable). Only the white :after switch position is animated now.</p><p>The next accessibility issue: keyboard focus. The previous toggles were difficult to use with keyboard only so I&#8217;ve applied a different label color and a box shadow to the toggle when it has focus:</p><pre><code>input.switch:focus ~ label
{
  color: #000;
}
input.switch:focus ~ label:before
{
  box-shadow: 0 0 0 3px #999;
}</code></pre><p>The result is possibly a little too subtle, but it&#8217;s easy to add your own effects:</p><p><img
src="http://blogs.sitepointstatic.com/images/tech/826-better-css3-toggle-switches-focus.png" width="214" height="64" alt="toggle focus" class="center" /></p><p>The focus effect works in Firefox, IE and Opera &#8212; but fails in Chrome 26? It looks like a browser bug unless anyone knows differently?</p><h2>More Webkit Woes</h2><p>The final problem: the toggle switches fail in mobile browsers using older versions of Webkit such as Safari on the iPad 1.0 and the Android browser. The engine supports labels, is happy with :checkbox selectors and displays the initial state, but doesn&#8217;t want to modify pseudo elements after the initial page load. I even broke my own requirements and added a little JavaScript, but the browser laughed at my feeble attempts and wouldn&#8217;t budge.</p><p>Pseudo element animation has only been added to Webkit recently. It&#8217;s frustrating and, unlike the old IE6/7 days, it&#8217;s difficult to find workarounds which don&#8217;t adversely affect other browsers.</p><p>Anyway, assuming legacy Webkit users aren&#8217;t part of your demographic, please <a
href="http://cssdeck.com/labs/full/better-css-toggle-switches">use the HTML/CSS code</a> however you like. Alternatively, you&#8217;ll need to add further (real) elements or JavaScript to make it work.</p><div
class='after-content-widget-1'><div
id="sitepointcontextualcontentmanagerwidget-5" class="widget widget_sitepointcontextualcontentmanagerwidget"><style>#targettedEOF { width: 99%; font-family: "Open Sans", Helvetica, Arial, sans-serif; border-radius: 4px; border: 1px dotted #47B4DC; }
#targettedEOF .targettedEOFcol { float: left; padding: 20px; }
#targettedEOF .targettedEOFbtn { clear: both; padding: 0; }
#targettedEOF h2 { margin-top: 10px; }
#targettedEOF .sptolbCTA { border: 0 none; border-bottom: 2px solid #85bb41; background-color: #91c352; color: white; margin: 0; padding: 1em 1em; border-radius: 4px; vertical-align: middle; text-align: center; font-weight: 700; font-size: 17px; display: inline-block; line-height: 0; text-shadow: -1px -1px 1px rgba(0,0,0,0.2); cursor: pointer; text-decoration: none;
}
#targettedEOF .sptolbCTA:hover { color: white; }
#targettedEOF .targettedEOFbtn p { padding: 0; margin: 0; }
.cat_javascript #targettedEOF h2, .cat_cloudspring #targettedEOF h2 { font-size: 1.267em; line-height: 1.158em; margin: 1.737em 0 0.579em 0; font-weight: bold; color: #0071D8; }
.cat_javascript #targettedEOF, .cat_cloudspring #targettedEOF { font-size: 1.5em; line-height: 1.467em; width: 100%; }
.cat_javascript #targettedEOF ul, .cat_cloudspring #targettedEOF ul { list-style: square; margin: 0 0 1.467em 1.467em; }</style><div
id="targettedEOF"><div
class="targettedEOFcol"> <a
href="https://learnable.com/books/jsjavascript1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=UltimateJavaScriptBundle"><img
src="https://learnable-images.s3.amazonaws.com/books/responsive1_medium.jpg" width="145"></a></div><div
class="targettedEOFcol"><h2>Learn Responsive Web Design</h2><ul><li>SitePoint's ebook: <a
href="https://learnable.com/books/responsive1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Jump Start Responsive Web Design</a></li><li><a
href="https://learnable.com/courses/responsive-web-design-key-concepts-2759?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Responsive Web Design: Key Concepts</a> online course</li><li>Unlimited access to <a
href="https://learnable.com/topics/front-end?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign"> SitePoint Premium Content</a></li></ul><p><a
class="sptolbCTA" href="https://learnable.com/?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign#pricing">Join Learnable $29</a> <span><strong>Includes all SitePoint books</strong></span></div><div
class="targettedEOFbtn"></div></div><div
class="dfp-ad show-desktop"><div
id="div-gpt-ad-1340873946991-4" style="width: 728px; height: 90px;"> <script type="text/javascript">googletag.cmd.push(function() { googletag.display("div-gpt-ad-1340873946991-4"); });</script> </div></div></div></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=K86-tjxPbSo:3juaXoMPDnY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=K86-tjxPbSo:3juaXoMPDnY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=K86-tjxPbSo:3juaXoMPDnY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?i=K86-tjxPbSo:3juaXoMPDnY:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SitepointFeed/~4/K86-tjxPbSo" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/better-css3-toggle-switches/feed/</wfw:commentRss> <slash:comments>7</slash:comments> <feedburner:origLink>http://www.sitepoint.com/better-css3-toggle-switches/</feedburner:origLink></item> <item><title>Introducing the new HTML5 template Tag</title><link>http://feedproxy.google.com/~r/SitepointFeed/~3/Sh5IhvBWdjI/</link> <comments>http://www.sitepoint.com/html5-template-tag/#comments</comments> <pubDate>Fri, 17 May 2013 17:02:34 +0000</pubDate> <dc:creator>Craig Buckler</dc:creator> <category><![CDATA[Ajax]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[HTML5]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[News]]></category> <category><![CDATA[Web standards]]></category> <category><![CDATA[DOM]]></category> <category><![CDATA[HTML5 Dev Center]]></category> <category><![CDATA[HTML5 Tutorials & Articles]]></category> <guid isPermaLink="false">http://www.sitepoint.com/?p=65576</guid> <description><![CDATA[Have you ever needed to reuse or repeat document fragments in your page? The W3C has finally agreed a standard way to define DOM templates -- Craig looks at the new HTML5 template tag.]]></description> <content:encoded><![CDATA[<p></p><p>Modern web applications use DOM manipulation to dynamically change areas of the page or insert values. A typical example is a table of figures; the initial page could return HTML column headers then initialize an Ajax request which returns several data records. The data is then appended to the table &#8212; <em>but how?</em> The developer has two choices:</p><ol><li>JavaScript is used to build HTML row strings or DOM fragments which are appended to the table. That seems easy until you need to make a change and must hunt around your JavaScript for the associated HTML code. To make life simpler, developers often return whole HTML string fragments from the Ajax call, but that makes the payload more verbose and opens the potential for Cross-Site Scripting attacks.</li><li>Alternatively, you create an empty first row in the HTML page which is used as a template for all other rows. That should be easier to maintain, but you&#8217;ll need to remove it from the DOM or style it with display:none to ensure it doesn&#8217;t appear.</li></ol><p>Neither solution is particularly elegant.</p><p>Fortunately, the <a
href="https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html">W3C has introduced a new <code>template</code> tag</a> which provides a mechanism to define HTML markup fragments as prototypes. <em>(Perhaps it will also appease those upset by the <a
href="/html5-hgroup-element-dropped/">demise of the hgroup element</a>!)</em></p><p>In essence, a template can be used to insert fragments of HTML code into your page, e.g.</p><pre><code>&lt;template id=&quot;mytablerow&quot;&gt;
&lt;tr&gt;
&lt;td class=&quot;record&quot;&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/template&gt;
</code></pre><p>The <code>template</code> code can be defined almost anywhere &#8212; the <code>head</code>, <code>body</code> or even a <code>frameset</code>. However:</p><ol><li>templates will not display</li><li>templates are not considered to be part of the document, i.e. using document.getElementById(&#8220;mytablerow&#8221;) will not return child nodes</li><li>templates are inactive until used, i.e. enclosed images will not download, media will not play, scripts will not run, etc.</li></ol><h2>Using templates</h2><p>To use a template, it must be cloned and inserted into the DOM. For example, assuming the following HTML:</p><pre><code>&lt;table id=&quot;mytable&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;td&gt;ID&lt;/td&gt;
&lt;td&gt;name&lt;/td&gt;
&lt;td&gt;twitter&lt;/td&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;!-- rows to be appended here --&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;!-- row template --&gt;
&lt;template id=&quot;mytablerow&quot;&gt;
&lt;tr&gt;
&lt;td class=&quot;record&quot;&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/template&gt;
</code></pre><p>We can clone a new row in JavaScript:</p><pre><code>// fetch tbody and row template
var	t = document.querySelector(&quot;#mytable tbody&quot;),
	row = document.getElementById(&quot;mytablerow&quot;);
// modify row data
var td = row.getElementsByTagName(&quot;td&quot;);
td[0].textContent = &quot;1&quot;;
td[1].textContent = &quot;SitePoint&quot;;
td[2].textContent = &quot;sitepointdotcom&quot;;
// clone row and insert into table
t.appendChild(row.content.cloneNode(true));
</code></pre><p>The important question: <em>can we use template tags?</em></p><p>Probably not just yet. It&#8217;s supported in the latest version of Chrome and Firefox nightlies. Opera will support the tag when it switches to <a
href="/blink-rendering-engine-google-chrome/">Blink</a>. No word from the IE and Safari teams yet, but a <a
href="http://jsfiddle.net/brianblakely/h3EmY/">template shim has been demonstrated on JSfiddle</a> should you wish to support all browsers.</p><p>Personally, I think the <code>template</code> tag is a great idea. It&#8217;s simple and standardizes templating techniques for HTML5 developers.</p><div
class='after-content-widget-1'><div
id="sitepointcontextualcontentmanagerwidget-5" class="widget widget_sitepointcontextualcontentmanagerwidget"><style>#targettedEOF { width: 99%; font-family: "Open Sans", Helvetica, Arial, sans-serif; border-radius: 4px; border: 1px dotted #47B4DC; }
#targettedEOF .targettedEOFcol { float: left; padding: 20px; }
#targettedEOF .targettedEOFbtn { clear: both; padding: 0; }
#targettedEOF h2 { margin-top: 10px; }
#targettedEOF .sptolbCTA { border: 0 none; border-bottom: 2px solid #85bb41; background-color: #91c352; color: white; margin: 0; padding: 1em 1em; border-radius: 4px; vertical-align: middle; text-align: center; font-weight: 700; font-size: 17px; display: inline-block; line-height: 0; text-shadow: -1px -1px 1px rgba(0,0,0,0.2); cursor: pointer; text-decoration: none;
}
#targettedEOF .sptolbCTA:hover { color: white; }
#targettedEOF .targettedEOFbtn p { padding: 0; margin: 0; }
.cat_javascript #targettedEOF h2, .cat_cloudspring #targettedEOF h2 { font-size: 1.267em; line-height: 1.158em; margin: 1.737em 0 0.579em 0; font-weight: bold; color: #0071D8; }
.cat_javascript #targettedEOF, .cat_cloudspring #targettedEOF { font-size: 1.5em; line-height: 1.467em; width: 100%; }
.cat_javascript #targettedEOF ul, .cat_cloudspring #targettedEOF ul { list-style: square; margin: 0 0 1.467em 1.467em; }</style><div
id="targettedEOF"><div
class="targettedEOFcol"> <a
href="https://learnable.com/books/jsjavascript1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=UltimateJavaScriptBundle"><img
src="https://learnable-images.s3.amazonaws.com/books/responsive1_medium.jpg" width="145"></a></div><div
class="targettedEOFcol"><h2>Learn Responsive Web Design</h2><ul><li>SitePoint's ebook: <a
href="https://learnable.com/books/responsive1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Jump Start Responsive Web Design</a></li><li><a
href="https://learnable.com/courses/responsive-web-design-key-concepts-2759?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Responsive Web Design: Key Concepts</a> online course</li><li>Unlimited access to <a
href="https://learnable.com/topics/front-end?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign"> SitePoint Premium Content</a></li></ul><p><a
class="sptolbCTA" href="https://learnable.com/?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign#pricing">Join Learnable $29</a> <span><strong>Includes all SitePoint books</strong></span></div><div
class="targettedEOFbtn"></div></div><div
class="dfp-ad show-desktop"><div
id="div-gpt-ad-1340873946991-4" style="width: 728px; height: 90px;"> <script type="text/javascript">googletag.cmd.push(function() { googletag.display("div-gpt-ad-1340873946991-4"); });</script> </div></div></div></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=Sh5IhvBWdjI:R4MjgxH_3Xs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=Sh5IhvBWdjI:R4MjgxH_3Xs:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=Sh5IhvBWdjI:R4MjgxH_3Xs:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?i=Sh5IhvBWdjI:R4MjgxH_3Xs:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SitepointFeed/~4/Sh5IhvBWdjI" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/html5-template-tag/feed/</wfw:commentRss> <slash:comments>10</slash:comments> <feedburner:origLink>http://www.sitepoint.com/html5-template-tag/</feedburner:origLink></item> <item><title>Crowdfunding a CSS Animation course – an experiment</title><link>http://feedproxy.google.com/~r/SitepointFeed/~3/S3COvCxe-GU/</link> <comments>http://www.sitepoint.com/crowdfunding-web-development-courses-an-experiment/#comments</comments> <pubDate>Fri, 17 May 2013 00:51:12 +0000</pubDate> <dc:creator>Claire Sawyers</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[CSS3]]></category> <category><![CDATA[Programming]]></category> <guid isPermaLink="false">http://www.sitepoint.com/?p=66287</guid> <description><![CDATA[During Triple time at SitePoint, we give our employees 3 days to pursue projects of their choice, much like Google's 20%. This project is an innovation born out of this…]]></description> <content:encoded><![CDATA[<p></p><p><em>During Triple time at SitePoint, we give our employees 3 days to pursue projects of their choice, much like Google&#8217;s 20%. This project is an innovation born out of this… Please share your feedback and get in behind it!</em></p><p>Would you want to learn CSS Animation from our CSS Guru, Alex Walker? If so, would you be prepared to crowdfund to make it happen?</p><p>We are running our own experiment to see if we can crowdfund a web development course, via a system we&#8217;ve built; <a
href="http://launchable.sitepoint.com/">Launchable</a>.</p><p>Hear Alex talk about the course he will produce if he meets his Launchable funding goal and pledge to support his project<br
/> <iframe
width="560" height="315" src="http://www.youtube.com/embed/hgcKC1ml6X8" frameborder="0" allowfullscreen></iframe></p><p><strong>About Launchable</strong><br
/> There&#8217;s heaps of people out there who want to create an online course, but never find the time &#8211; mostly as there&#8217;s no way to know what your ROI will be.<br
/> What if you could find out exactly how worthwhile it would be, before you record a single thing? We think this would be a super useful service. That&#8217;s why we created and are testing Launchable with one pilot project &#8211; CSS Animation. It&#8217;s not just a test. Alex will actually make and deliver this course if the project receives $2000 in pledges. If this does well, we&#8217;ll look at making the platform open for more instructors to apply and begin pitching.</p><p><a
href="http://launchable.sitepoint.com/">Visit Launchable today</a> to pledge to purchase his course if you think it should be produced. Share your feedback if you think this concept rocks or we should go back to the drawing board. It&#8217;s early adopters like you who can help shape this into a reality!</p><div
class='after-content-widget-1'><div
id="sitepointcontextualcontentmanagerwidget-5" class="widget widget_sitepointcontextualcontentmanagerwidget"><style>#targettedEOF { width: 99%; font-family: "Open Sans", Helvetica, Arial, sans-serif; border-radius: 4px; border: 1px dotted #47B4DC; }
#targettedEOF .targettedEOFcol { float: left; padding: 20px; }
#targettedEOF .targettedEOFbtn { clear: both; padding: 0; }
#targettedEOF h2 { margin-top: 10px; }
#targettedEOF .sptolbCTA { border: 0 none; border-bottom: 2px solid #85bb41; background-color: #91c352; color: white; margin: 0; padding: 1em 1em; border-radius: 4px; vertical-align: middle; text-align: center; font-weight: 700; font-size: 17px; display: inline-block; line-height: 0; text-shadow: -1px -1px 1px rgba(0,0,0,0.2); cursor: pointer; text-decoration: none;
}
#targettedEOF .sptolbCTA:hover { color: white; }
#targettedEOF .targettedEOFbtn p { padding: 0; margin: 0; }
.cat_javascript #targettedEOF h2, .cat_cloudspring #targettedEOF h2 { font-size: 1.267em; line-height: 1.158em; margin: 1.737em 0 0.579em 0; font-weight: bold; color: #0071D8; }
.cat_javascript #targettedEOF, .cat_cloudspring #targettedEOF { font-size: 1.5em; line-height: 1.467em; width: 100%; }
.cat_javascript #targettedEOF ul, .cat_cloudspring #targettedEOF ul { list-style: square; margin: 0 0 1.467em 1.467em; }</style><div
id="targettedEOF"><div
class="targettedEOFcol"> <a
href="https://learnable.com/books/jsjavascript1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=UltimateJavaScriptBundle"><img
src="https://learnable-images.s3.amazonaws.com/books/responsive1_medium.jpg" width="145"></a></div><div
class="targettedEOFcol"><h2>Learn Responsive Web Design</h2><ul><li>SitePoint's ebook: <a
href="https://learnable.com/books/responsive1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Jump Start Responsive Web Design</a></li><li><a
href="https://learnable.com/courses/responsive-web-design-key-concepts-2759?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Responsive Web Design: Key Concepts</a> online course</li><li>Unlimited access to <a
href="https://learnable.com/topics/front-end?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign"> SitePoint Premium Content</a></li></ul><p><a
class="sptolbCTA" href="https://learnable.com/?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign#pricing">Join Learnable $29</a> <span><strong>Includes all SitePoint books</strong></span></div><div
class="targettedEOFbtn"></div></div><div
class="dfp-ad show-desktop"><div
id="div-gpt-ad-1340873946991-4" style="width: 728px; height: 90px;"> <script type="text/javascript">googletag.cmd.push(function() { googletag.display("div-gpt-ad-1340873946991-4"); });</script> </div></div></div></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=S3COvCxe-GU:bTLl2xSsI1c:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=S3COvCxe-GU:bTLl2xSsI1c:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=S3COvCxe-GU:bTLl2xSsI1c:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?i=S3COvCxe-GU:bTLl2xSsI1c:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SitepointFeed/~4/S3COvCxe-GU" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/crowdfunding-web-development-courses-an-experiment/feed/</wfw:commentRss> <slash:comments>1</slash:comments> <feedburner:origLink>http://www.sitepoint.com/crowdfunding-web-development-courses-an-experiment/</feedburner:origLink></item> <item><title>Learn JavaScript Online</title><link>http://feedproxy.google.com/~r/SitepointFeed/~3/a4FHCu204PU/</link> <comments>http://www.sitepoint.com/learn-javascript-online/#comments</comments> <pubDate>Thu, 16 May 2013 14:15:19 +0000</pubDate> <dc:creator>Ricky Onsman</dc:creator> <category><![CDATA[JavaScript]]></category> <category><![CDATA[Programming]]></category> <guid isPermaLink="false">http://www.sitepoint.com/?p=66222</guid> <description><![CDATA[By looking at what our loyal SitePoint audience has been doing and loving, we've compiled three quick lists with options to get you learning some serious JavaScript.]]></description> <content:encoded><![CDATA[<p></p><p>We know that people acquire skills, adopt techniques, learn <em>any</em>thing in different ways, and timeframes, and formats, and with wildly varying expectations.</p><p>Between SitePoint and Learnable, we&#8217;re building a network of ways you can acquire web skills as you want and need them.</p><p>Below are three ways you can learn a lot of JavaScript online. By looking at what our loyal SitePoint audience has been doing and loving, we have compiled three quick lists with options to get you learning some serious JavaScript.</p><p>Whether you&#8217;re solving an immediate problem, expanding your skill set, starting from scratch or exploring advanced techniques, here are some options:</p><h2>Getting started &amp; key concepts</h2><p>For real beginners or those who feel like they&#8217;re using JavaScript without really knowing it and are ready to get to know it properly.</p><ul><li>Tutorial: <a
href="http://www.sitepoint.com/javascript-custom-events/">How to Create Custom Events in JavaScript</a></li><li>eBook: <a
href="https://learnable.com/books/jsjavascript1">Jump Start JavaScript</a> (PREMIUM)</li><li>Course: <a
href="https://learnable.com/courses/javascript-programming-for-the-web-40">JavaScript Programming for the Web</a> (PREMIUM)</li><li>Course: <a
href="https://learnable.com/courses/jquery-fundamentals-1132">jQuery Fundamentals</a> (PREMIUM)</li><li>eBook: <a
href="https://learnable.com/books/jquery1">jQuery: Novice to Ninja</a> (PREMIUM)</li><li>Tutorial: <a
href="http://www.sitepoint.com/javascript-this-event-handlers/">JavaScript ‘this’ and Event Handlers</a></li></ul><h2>All time greatest JavaScript tutorials</h2><p>For those who know the basics and want to experiment with techniques, we’ve hand picked a selection of our all time greatest JavaScript tutorials.</p><ul><li><a
href="http://www.sitepoint.com/multi-threading-javascript/">Multi-threading in JavaScript</a></li><li><a
href="http://www.sitepoint.com/javascript-json-serialization/">Cross-browser JSON Serialization in JavaScript</a></li><li><a
href="http://www.sitepoint.com/creating-accurate-timers-in-javascript/">Creating Accurate Timers in JavaScript</a></li><li><a
href="http://www.sitepoint.com/javascript-sprite-animation-using-jquery/">JavaScript Sprite Animation Using jQuery</a></li></ul><h2>Trending topics and rising stars</h2><p>For those who feel ready enough for a deeper dive into some of the more cutting edge JavaScript technology.</p><ul><li>Tutorial: <a
href="http://www.sitepoint.com/introduction-to-fabric-js/">Introduction to Fabric.js</a></li><li>Tutorial: <a
href="http://www.sitepoint.com/understanding-requirejs-for-effective-javascript-module-loading/">Understanding RequireJS for Effective JavaScript Module Loading</a></li><li>Video: <a
href="https://learnable.com/jumpcasts/intro-to-angular-js-63">Intro to Angular.js</a></li><li>Course: <a
href="https://learnable.com/courses/backbone-js-a-practical-beginner-s-guide-2742">Backbone.JS: A practical beginner&#8217;s guide</a> (PREMIUM)</li><li>eBook: <a
href="https://learnable.com/books/coffeescript1">Jump Start CoffeeScript</a> (PREMIUM)</li><li>eBook: <a
href="https://learnable.com/books/nodejs1">Jump Start Node.js</a> (PREMIUM)</li></ul><h2>Join Learnable</h2><p>Buy the premium items individually by following the links or get access to all of them and a lot more with a <a
href="https://learnable.com/#pricing" target="_blank">Learnable membership</a>.</p><p>Today, Learnable members found <a
href="https://learnable.com/books/jsjavascript1">Jump Start JavaScript</a> right there, ready to download. It makes following the learning curve a lot easier if you have instant multi-format access to the basics when you need them and new developments as they emerge.</p><div
class='after-content-widget-1'><div
id="sitepointcontextualcontentmanagerwidget-5" class="widget widget_sitepointcontextualcontentmanagerwidget"><style>#targettedEOF { width: 99%; font-family: "Open Sans", Helvetica, Arial, sans-serif; border-radius: 4px; border: 1px dotted #47B4DC; }
#targettedEOF .targettedEOFcol { float: left; padding: 20px; }
#targettedEOF .targettedEOFbtn { clear: both; padding: 0; }
#targettedEOF h2 { margin-top: 10px; }
#targettedEOF .sptolbCTA { border: 0 none; border-bottom: 2px solid #85bb41; background-color: #91c352; color: white; margin: 0; padding: 1em 1em; border-radius: 4px; vertical-align: middle; text-align: center; font-weight: 700; font-size: 17px; display: inline-block; line-height: 0; text-shadow: -1px -1px 1px rgba(0,0,0,0.2); cursor: pointer; text-decoration: none;
}
#targettedEOF .sptolbCTA:hover { color: white; }
#targettedEOF .targettedEOFbtn p { padding: 0; margin: 0; }
.cat_javascript #targettedEOF h2, .cat_cloudspring #targettedEOF h2 { font-size: 1.267em; line-height: 1.158em; margin: 1.737em 0 0.579em 0; font-weight: bold; color: #0071D8; }
.cat_javascript #targettedEOF, .cat_cloudspring #targettedEOF { font-size: 1.5em; line-height: 1.467em; width: 100%; }
.cat_javascript #targettedEOF ul, .cat_cloudspring #targettedEOF ul { list-style: square; margin: 0 0 1.467em 1.467em; }</style><div
id="targettedEOF"><div
class="targettedEOFcol"> <a
href="https://learnable.com/books/jsjavascript1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=UltimateJavaScriptBundle"><img
src="https://learnable-images.s3.amazonaws.com/books/responsive1_medium.jpg" width="145"></a></div><div
class="targettedEOFcol"><h2>Learn Responsive Web Design</h2><ul><li>SitePoint's ebook: <a
href="https://learnable.com/books/responsive1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Jump Start Responsive Web Design</a></li><li><a
href="https://learnable.com/courses/responsive-web-design-key-concepts-2759?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Responsive Web Design: Key Concepts</a> online course</li><li>Unlimited access to <a
href="https://learnable.com/topics/front-end?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign"> SitePoint Premium Content</a></li></ul><p><a
class="sptolbCTA" href="https://learnable.com/?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign#pricing">Join Learnable $29</a> <span><strong>Includes all SitePoint books</strong></span></div><div
class="targettedEOFbtn"></div></div><div
class="dfp-ad show-desktop"><div
id="div-gpt-ad-1340873946991-4" style="width: 728px; height: 90px;"> <script type="text/javascript">googletag.cmd.push(function() { googletag.display("div-gpt-ad-1340873946991-4"); });</script> </div></div></div></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=a4FHCu204PU:IDYQX2CDcKs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=a4FHCu204PU:IDYQX2CDcKs:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=a4FHCu204PU:IDYQX2CDcKs:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?i=a4FHCu204PU:IDYQX2CDcKs:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SitepointFeed/~4/a4FHCu204PU" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/learn-javascript-online/feed/</wfw:commentRss> <slash:comments>1</slash:comments> <feedburner:origLink>http://www.sitepoint.com/learn-javascript-online/</feedburner:origLink></item> <item><title>Does Grammar Even Matter Any More?</title><link>http://feedproxy.google.com/~r/SitepointFeed/~3/bFtkavXzTSw/</link> <comments>http://www.sitepoint.com/does-grammar-even-matter-any-more/#comments</comments> <pubDate>Thu, 16 May 2013 12:02:16 +0000</pubDate> <dc:creator>Georgina Laidlaw</dc:creator> <category><![CDATA[Content strategy]]></category> <guid isPermaLink="false">http://www.sitepoint.com/?p=66242</guid> <description><![CDATA[The short answer: I can haz cheezburger. The long answer: yes, more than ever. Georgina Laidlaw recommends a flexible approach when applying print-based rules of text usage to web content.]]></description> <content:encoded><![CDATA[<p></p><p>The short answer: I can haz cheezburger.</p><p>The long answer: yes, more than ever. Let&#8217;s see why.</p><h2>Old-skool rulez</h2><p>Many of the people who argue against the web&#8217;s flaky-seeming attitude to grammar were taught language via traditional means at school—and excelled in it.</p><p>They understand the rules and they like to apply them. They feel that decent English is a reflection on the individual who produces it, and shows a respect for the person who hears or reads it. And often, but not always, they are particularly enamoured by print media.</p><p>These are the writers who argue that you can&#8217;t start a sentence with &#8220;and&#8221; or &#8220;but&#8221;; that serial commas are either the holy grail or the devil&#8217;s work; that contractions are for face-to-face conversation, not business writing.</p><p>Are they right?</p><h2>New media constraints</h2><p>Of course they&#8217;re right—those are (some of) the rules of English usage.</p><p>However, new media presents new constraints on language—constraints for which some flexibility is required.</p><p>And the success of sites like <a
href="http://icanhas.cheezburger.com/">icanhazcheezburger</a> indicate that flexibility can pay off in terms of user engagement and audience growth.<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><h3>Constraint #1: technology</h3><p>It&#8217;s more difficult to read and comprehend digital text than print text. There, I said it.</p><p>This is one key reason why I think language has become less formal online. Since communication&#8217;s more difficult in this medium, content creators have tried to make communicating as simple as possible.</p><h3>Constraint #2: Low barriers to entry</h3><p>The web has much lower barriers to entry than traditional media.</p><p>This is a major advantage for those of us with something to sell—or tell—but also, it&#8217;s another reason why the web&#8217;s less formal than traditional media.</p><h3>Constraint #3: User interaction</h3><p>The web&#8217;s interactive, and gives us far more information about how effective our communication is than traditional media ever could.</p><p>So, for example, we all know that web users scan, and if we&#8217;re building content for them to use, we need to consider that.</p><p>But the web also entails a broader spectrum of communication than traditional media.</p><p>These factors affect everything from whether we use a sales video, to whether we use a semi-colon in the text that invites people to view it.</p><h2>Striking a compromise</h2><p>You only have to look at a few lolcats to realise that the web is a place where pretty much anything goes, language-wise.</p><p>Does that mean &#8220;proper&#8221; English is dead?</p><p>Well, that depends on one thing: your brand. Your brand has values—hopefully some that correlate with those of its target audience. It has a corresponding tone of voice, and that tone is communicated through your use of language.</p><p>If you choose to adhere to the strictest grammar rules, you can be sure that you&#8217;ll alienate some users. If you choose to compose your website in lolcats language, you can expect the same result (unless of course your business <em>is</em> a lolcats site).</p><p>The right compromise lies in the territory that exists between your brand and its customers. Speak to your audience using the aspects of their language that align with your brand and its values.</p><p><img
class="alignnone size-full wp-image-66243" alt="Camera Awesome home" src="http://www.sitepoint.com/wp-content/uploads/1/files/2013/05/Screen-Shot-2013-05-15-at-5.56.56-PM.png" width="464" height="569" /></p><p>Each of us alters the way we talk depending on who we&#8217;re speaking to—and it&#8217;s that, not the medium, that should dictate how closely you stick to the English usage rules, as well as <em>which ones</em> you stick to, in your web copy and content.</p><p><img
class="alignnone wp-image-66244" alt="Gawker home headlines" src="http://www.sitepoint.com/wp-content/uploads/1/files/2013/05/Screen-Shot-2013-05-15-at-6.03.54-PM.png" width="626" height="447" /></p><p>In this context, it&#8217;s the people who know the rules of grammar, punctuation, and spelling inside-out—and therefore know when and how to break them—that are able to pitch their online message to greatest effect.</p><p>But hang on. You&#8217;re not a grammarian: you&#8217;re a developer, or a CEO, or a founder. Where does this leave you?</p><p>We&#8217;ll answer that question next week, as we look at user testing your copy to see if it&#8217;s hitting the mark.</p><div
class='after-content-widget-1'><div
id="sitepointcontextualcontentmanagerwidget-5" class="widget widget_sitepointcontextualcontentmanagerwidget"><style>#targettedEOF { width: 99%; font-family: "Open Sans", Helvetica, Arial, sans-serif; border-radius: 4px; border: 1px dotted #47B4DC; }
#targettedEOF .targettedEOFcol { float: left; padding: 20px; }
#targettedEOF .targettedEOFbtn { clear: both; padding: 0; }
#targettedEOF h2 { margin-top: 10px; }
#targettedEOF .sptolbCTA { border: 0 none; border-bottom: 2px solid #85bb41; background-color: #91c352; color: white; margin: 0; padding: 1em 1em; border-radius: 4px; vertical-align: middle; text-align: center; font-weight: 700; font-size: 17px; display: inline-block; line-height: 0; text-shadow: -1px -1px 1px rgba(0,0,0,0.2); cursor: pointer; text-decoration: none;
}
#targettedEOF .sptolbCTA:hover { color: white; }
#targettedEOF .targettedEOFbtn p { padding: 0; margin: 0; }
.cat_javascript #targettedEOF h2, .cat_cloudspring #targettedEOF h2 { font-size: 1.267em; line-height: 1.158em; margin: 1.737em 0 0.579em 0; font-weight: bold; color: #0071D8; }
.cat_javascript #targettedEOF, .cat_cloudspring #targettedEOF { font-size: 1.5em; line-height: 1.467em; width: 100%; }
.cat_javascript #targettedEOF ul, .cat_cloudspring #targettedEOF ul { list-style: square; margin: 0 0 1.467em 1.467em; }</style><div
id="targettedEOF"><div
class="targettedEOFcol"> <a
href="https://learnable.com/books/jsjavascript1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=UltimateJavaScriptBundle"><img
src="https://learnable-images.s3.amazonaws.com/books/responsive1_medium.jpg" width="145"></a></div><div
class="targettedEOFcol"><h2>Learn Responsive Web Design</h2><ul><li>SitePoint's ebook: <a
href="https://learnable.com/books/responsive1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Jump Start Responsive Web Design</a></li><li><a
href="https://learnable.com/courses/responsive-web-design-key-concepts-2759?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Responsive Web Design: Key Concepts</a> online course</li><li>Unlimited access to <a
href="https://learnable.com/topics/front-end?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign"> SitePoint Premium Content</a></li></ul><p><a
class="sptolbCTA" href="https://learnable.com/?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign#pricing">Join Learnable $29</a> <span><strong>Includes all SitePoint books</strong></span></div><div
class="targettedEOFbtn"></div></div><div
class="dfp-ad show-desktop"><div
id="div-gpt-ad-1340873946991-4" style="width: 728px; height: 90px;"> <script type="text/javascript">googletag.cmd.push(function() { googletag.display("div-gpt-ad-1340873946991-4"); });</script> </div></div></div></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=bFtkavXzTSw:u0kr-xM1nwA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=bFtkavXzTSw:u0kr-xM1nwA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=bFtkavXzTSw:u0kr-xM1nwA:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?i=bFtkavXzTSw:u0kr-xM1nwA:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SitepointFeed/~4/bFtkavXzTSw" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/does-grammar-even-matter-any-more/feed/</wfw:commentRss> <slash:comments>14</slash:comments> <feedburner:origLink>http://www.sitepoint.com/does-grammar-even-matter-any-more/</feedburner:origLink></item> <item><title>We Talked JavaScript with the Experts – The Transcript</title><link>http://feedproxy.google.com/~r/SitepointFeed/~3/H2p0etyTivA/</link> <comments>http://www.sitepoint.com/we-talked-javascript-with-the-experts-here-is-the-transcript/#comments</comments> <pubDate>Thu, 16 May 2013 02:11:44 +0000</pubDate> <dc:creator>Sarah Hawk</dc:creator> <category><![CDATA[Community]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[talk with the experts]]></category> <guid isPermaLink="false">http://www.sitepoint.com/?p=66277</guid> <description><![CDATA[The subject of this morning's Talk with the Experts session was JavaScript and our expert was Ara Pehlivanian – co-author of our latest book, Jump Start JavaScript. Here is how it went down...]]></description> <content:encoded><![CDATA[<p></p><p>The subject of this morning&#8217;s <em>Talk with the Experts</em> session was JavaScript and our expert was Ara Pehlivanian – co-author of our latest book, <a
title="Jump Start JavaScript" href="https://learnable.com/books/jsjavascript1" target="_blank">Jump Start JavaScript</a>. It was a busy session and the questions varied from the basics to the advanced, making for a refreshing hour. Ara fended off the hordes admirably and even managed to have a good time doing so. Impressive.</p><p>A number of good resources came out of the session, and to save you filtering through the entire transcript, they are listed below. If you missed the session and want to see how it all went down, then you&#8217;re in luck &#8211; you&#8217;ll also find the transcript in its entirety below.</p><p><strong>Resources:</strong></p><p>Ara&#8217;s book &#8211; <a
title="Jump Start JavaScript" href="https://learnable.com/books/jsjavascript1" target="_blank">Jump Start JavaScript</a> (you can <a
title="Ch1 of Jump Start JavaScript" href="https://learnable.com/books/jsjavascript1/online/ch01.html" target="_blank">preview the first chapter</a> for free)<br
/> An interesting article on <a
title="Article on learning programming" href="http://worrydream.com/LearnableProgramming/" target="_blank">how to help people to learn programming</a>.<br
/> Douglas Crockford&#8217;s <a
title="Douglas Crockford" href="http://javascript.crockford.com/" target="_blank">awesome JavaScript resources<br
/> </a>An interesting <a
title="Prototypes" href="http://dailyjs.com/2012/05/21/js101-prototype/" target="_blank">article on prototypes<br
/> </a>A couple of JS linting tools: <a
title="JS Lint" href="http://www.jslint.com/" target="_blank">JSLint</a> &amp; <a
title="JSHint" href="http://www.jshint.com/" target="_blank">JSHint<br
/> </a><a
title="Accessing the debugger in a browser" href="https://learnable.com/books/jsjavascript1/online/ch01.html#d5e162" target="_blank">How to activate the browser&#8217;s console to get access to the debugger<br
/> </a><a
title="Mozilla - JavaScript resources" href="https://developer.mozilla.org/en-US/docs/JavaScript" target="_blank">Mozilla&#8217;s JS resource site<br
/> </a><a
title="WebPlatform.org" href="http://docs.webplatform.org/wiki/javascript" target="_blank">JavaScript resources on WebPlatform.org<br
/> </a><a
title="Brackets" href="http://brackets.io/" target="_blank">Brackets</a> &#8211; an open source code editor<br
/> <a
title="jQuery on Github" href="https://github.com/jquery/jquery" target="_blank">jQuery on Github<br
/> </a><a
title="YUI" href="https://github.com/yui/yui3" target="_blank">YUI on Github<br
/> </a><a
title="Backbone" href="https://github.com/documentcloud/backbone" target="_blank">Backbone on Github<br
/> </a><a
title="Underscore" href="https://github.com/documentcloud/underscore" target="_blank">Underscore on Github<br
/> </a>And finally &#8211; some JS Templating tools: <a
title="Mustache JS" href="https://github.com/janl/mustache.js/" target="_blank">Mustache JS</a>  <a
title="Handlebar JS" href="http://handlebarsjs.com/" target="_blank">Handlebars JS</a> and <a
title="Underscore" href="http://underscorejs.org/#template" target="_blank">Underscore</a></p><p>If you missed this session because you didn&#8217;t know about it, make sure you <a
title="Email notifications of future sessions" href="http://www.facebook.com/sitepoint/app_115462065200508" target="_blank">sign up for email notifications</a> of future sessions here.</p><p>And lastly, <a
title="Talk with the Experts" href="https://experts.learnable.com/" target="_blank">next week we&#8217;re trying something a bit different</a>. Our in-house CSS guru Alex Walker will be helping you out with any tricky CSS issues that you might be having, so don&#8217;t miss that one.</p><p>And now&#8230; the transcript. Enjoy.</p><p><span
class="irc-date">[21:23]</span> <span
class="irc-black">&lt;HAWK&gt; Hey everyone &#8211; we&#8217;ll be kicking off shortly. Feel free to introduce yourselves in the mean time. </span></p><p><span
class="irc-date">[21:23]</span> <span
class="irc-black">&lt;Ara&gt; Hi, my name is Ara and I co-authored Jump Start JavaScript with Don Nguyen. :)</span></p><p><span
class="irc-date">[21:24]</span> <span
class="irc-black">&lt;codepo8&gt; My name is Chris and I love the web</span></p><p><span
class="irc-date">[21:25]</span> <span
class="irc-black">&lt;HAWK&gt; I&#8217;m Hawk, and I&#8217;m Community Manager at SitePoint &#8211; I&#8217;ll be moderating this session</span></p><p><span
class="irc-date">[21:30]</span> <span
class="irc-black">&lt;HAWK&gt; Right &#8211; so we may as well kick off</span></p><p><span
class="irc-date">[21:30]</span> <span
class="irc-black">&lt;HAWK&gt; There are only two things that you really need to know. You can @ tag people to get their attention, and you can ask questions at any time.</span></p><p><span
class="irc-date">[21:30]</span> <span
class="irc-black">&lt;HAWK&gt; If Ara is answering someone else, I&#8217;ll queue them for him</span></p><p><span
class="irc-date">[21:31]</span> <span
class="irc-black">&lt;Ara&gt; So, the one thing I found interesting while writing the book was trying to figure out what order to explain stuff in.</span></p><p><span
class="irc-date">[21:31]</span> <span
class="irc-black">&lt;HAWK&gt; I assume everyone knows that Ara is our expert, and he is author of our latest book &#8211; JumpStart JavaScript, which launches today</span></p><p><span
class="irc-date">[21:31]</span> <span
class="irc-black">&lt;HAWK&gt; <a
href="https://learnable.com/books/jsjavascript1">https://learnable.com/books/jsjavascript1</a></span></p><p><span
class="irc-date">[21:33]</span> <span
class="irc-black">&lt;Ara&gt; A lot of things are interdependent. So, for example, when explaining arrays, there were a few instances where you could do stuff with arrays using functions, but we hadn&#8217;t covered functions yet&#8230;</span></p><p><span
class="irc-date">[21:33]</span> <span
class="irc-black">&lt;Ara&gt; &#8230;so it was one of those, &#8220;we&#8217;ll touch on this in more detail later&#8221; situations.</span></p><p><span
class="irc-date">[21:33]</span> <span
class="irc-black">&lt;Ara&gt; It happened a few times.</span></p><p><span
class="irc-date">[21:33]</span> <span
class="irc-black">&lt;codepo8&gt; it is tricky</span></p><p><span
class="irc-date">[21:33]</span> <span
class="irc-black">&lt;Sagar&gt; It is a good line of thinking.</span></p><p><span
class="irc-date">[21:33]</span> <span
class="irc-black">&lt;codepo8&gt; personally I want &#8220;hello world&#8221; to die in a big fire. </span></p><p><span
class="irc-date">[21:33]</span> <span
class="irc-black">&lt;johnlacey&gt; lol. I love &#8220;Hello world.&#8221;</span></p><p><span
class="irc-date">[21:33]</span> <span
class="irc-black">&lt;HAWK&gt; Yeah &#8211; although there is something to be said for &#8220;Hello World&#8221;</span></p><p><span
class="irc-date">[21:33]</span> <span
class="irc-black">&lt;codepo8&gt; explaining concepts in context gets people much more excited. </span></p><p><span
class="irc-date">[21:34]</span> <span
class="irc-black">&lt;MalCurtis&gt; There should be a a generic &#8216;basics of programming&#8217; book that is language agnostic, that everyone is required to read before reading any other programming book</span></p><p><span
class="irc-date">[21:34]</span> <span
class="irc-black">&lt;Ara&gt; Sadly, I did use &#8220;Hello, world.&#8221; once or twice. But I think I slipped in a few &#8220;World dominations&#8221; as well.</span></p><p><span
class="irc-date">[21:34]</span> <span
class="irc-black">&lt;Ara&gt; ;)</span></p><p><span
class="irc-date">[21:34]</span> <span
class="irc-black">&lt;Velochicdunord&gt; Yes. One of my questions as a CS student is simply where to start with the existing libraries and APIs</span></p><p><span
class="irc-date">[21:34]</span> <span
class="irc-black">&lt;MalCurtis&gt; Because every book has to cover that ad infinitum</span></p><p><span
class="irc-date">[21:34]</span> <span
class="irc-black">&lt;steven&gt; MalCurtis, The Art of Computer Programming :P</span></p><p><span
class="irc-date">[21:35]</span> <span
class="irc-black">&lt;codepo8&gt; Learnable programming is trying to disrupt that idea. <a
href="http://worrydream.com/LearnableProgramming/">http://worrydream.com/LearnableProgramming/</a> and I&#8217;ve seen people get jumpstarted with this approach. </span></p><p><span
class="irc-date">[21:35]</span> <span
class="irc-black">&lt;MalCurtis&gt; steven JumpStart: Every Language&#8230; ever.</span></p><p><span
class="irc-date">[21:35]</span> <span
class="irc-black">&lt;Velochicdunord&gt; I meant with the Javascript APIs. For instance, which ones are the most useful for web dev versus games.</span></p><p><span
class="irc-date">[21:35]</span> <span
class="irc-black">&lt;Ara&gt; Velochicdunord: a lot of the core API is useful in both scenarios</span></p><p><span
class="irc-date">[21:36]</span> <span
class="irc-black">&lt;Ara&gt; Velochicdunord: Or do you mean DOM API?</span></p><p><span
class="irc-date">[21:37]</span> <span
class="irc-black">&lt;codepo8&gt; starting with a game is dangerous. To make games work you need to cut a lot of corners and introduce a lot of concepts only applicable to a game, like the ticker and the main loop. You never need this in a &#8220;web site&#8221; or &#8220;web app&#8221; scenario. </span></p><p><span
class="irc-date">[21:37]</span> <span
class="irc-black">&lt;Ramy&gt; so is simply javascript book which was i think in 2007 has obsoleted teaching way ?</span></p><p><span
class="irc-date">[21:37]</span> <span
class="irc-black">&lt;Ara&gt; Velochicdunord : If you&#8217;re building a game, the majority of it will be built using the core language&#8217;s logic operators, data manipulation, etc&#8230; it&#8217;s when you get to the rendering that the choice of game vs. web is made.</span></p><p><span
class="irc-date">[21:38]</span> <span
class="irc-black">&lt;HAWK&gt; Ramy Simply JavaScript is still a valid resource but as you say, it was written a while back, hence this new book </span></p><p><span
class="irc-date">[21:38]</span> <span
class="irc-black">&lt;Ara&gt; You might choose to render your game using Canvas or you might use sprites manipulated in the DOM</span></p><p><span
class="irc-date">[21:38]</span> <span
class="irc-black">&lt;Ramy&gt; thanks HAWK for reply :)</span></p><p><span
class="irc-date">[21:38]</span> <span
class="irc-black">&lt;brick&gt; @Ara what about browser dependencies? isn&#8217;t it safer to use jQuery ?</span></p><p><span
class="irc-date">[21:38]</span> <span
class="irc-black">&lt;Velochicdunord&gt; OK &#8211; so look at the DOM (which I haven&#8217;t done yet) :P</span></p><p><span
class="irc-date">[21:39]</span> <span
class="irc-black">&lt;Ara&gt; Ramy: I wouldn&#8217;t say it&#8217;s obsolete but JavaScript has continued to evolve so we need to keep up with that evolution.</span></p><p><span
class="irc-date">[21:39]</span> <span
class="irc-black">&lt;Velochicdunord&gt; So &#8211; which bits are best for which uses? The available libraries multiply monthly. </span></p><p><span
class="irc-date">[21:39]</span> <span
class="irc-black">&lt;Ara&gt; brick: It&#8217;s definitely safer and a big time saver, but it&#8217;s always better to know what&#8217;s going on inside the library by having a firm grasp of native JavaScript.</span></p><p><span
class="irc-date">[21:39]</span> <span
class="irc-black">&lt;Ramy&gt; Thanks Ara :)</span></p><p><span
class="irc-date">[21:40]</span> <span
class="irc-black">&lt;HAWK&gt; To everyone else in the session &#8211; don&#8217;t wait for a gap if you have questions. Jump in and I&#8217;ll queue them.</span></p><p><span
class="irc-date">[21:40]</span> <span
class="irc-black">&lt;Ara&gt; Velochicdunord: the DOM is basically the web page&#8217;s HTML converted into an hierarchy of objects. Working with the DOM means updating the web page.</span></p><p><span
class="irc-date">[21:40]</span> <span
class="irc-black">&lt;JoshySav&gt; Just joined: One question: jQuery or plain javascript?</span></p><p><span
class="irc-date">[21:41]</span> <span
class="irc-black">&lt;Ara&gt; JoshySav: depends on what you&#8217;re doing. More often than not you don&#8217;t want to reinvent the wheel so, jQuery. But you won&#8217;t write 100% of your code in jQuery, so that&#8217;s where native JavaScript comes in. Also, knowing what jQuery is doing is good.</span></p><p><span
class="irc-date">[21:41]</span> <span
class="irc-black">&lt;brick&gt; I hear an echo</span></p><p><span
class="irc-date">[21:42]</span> <span
class="irc-black">&lt;johnlacey&gt; If you&#8217;re doing something simple you may want to avoid the extra weight of JQuery.</span></p><p><span
class="irc-date">[21:42]</span> <span
class="irc-black">&lt;Ara&gt; JoshySav: Also, as JavaScript evolves, a lot of what jQuery used to do is becoming natively available in browsers. For example, for a long time, we used to code getElementsByClassName by hand. Now, libraries hand off to the native method if it exists.</span></p><p><span
class="irc-date">[21:42]</span> <span
class="irc-black">&lt;Ara&gt; johnlacey: Yep. It&#8217;s really a decision to be made on a case by case basis.</span></p><p><span
class="irc-date">[21:42]</span> <span
class="irc-black">&lt;Ara&gt; brick: apologies :)</span></p><p><span
class="irc-date">[21:42]</span> <span
class="irc-black">&lt;JoshySav&gt; Awesome thanks :)</span></p><p><span
class="irc-date">[21:43]</span> <span
class="irc-black">&lt;johnlacey&gt; @Ara &#8212; So any rookie mistakes you think beginners to Javascript should be particularly aware of? </span></p><p><span
class="irc-date">[21:43]</span> <span
class="irc-black">&lt;JoshySav&gt; Also one other question, why are so many technologies on the web using JavaScript?</span></p><p><span
class="irc-date">[21:43]</span> <span
class="irc-black">&lt;codepo8&gt; A lot of jQuery was needed to plug the holes in browser support and simplify complex ways of accessing the document. This has changed. Browsers are more compliant with the standards and a lot of what we use jQuery for can be done in CSS and there it can be hardware accellerated and memory optimised by the browser for you.</span></p><p><span
class="irc-date">[21:44]</span> <span
class="irc-black">&lt;HAWK&gt; johnlacey &#8211; I&#8217;d say relying on it, considering these days so many people have it disabled ;)</span></p><p><span
class="irc-date">[21:44]</span> <span
class="irc-black">&lt;johnlacey&gt; @Hawk &#8212; Absolutely. That&#8217;s my fear. lol</span></p><p><span
class="irc-date">[21:44]</span> <span
class="irc-black">&lt;Ara&gt; johnlacey: variable scoping can be an issue. If you don&#8217;t understand variable scope, you can potentially overwrite data and cause errors. Also, understanding type coercion is another one. Not knowing the difference between == and === could potentially lead to unintended consequences.</span></p><p><span
class="irc-date">[21:44]</span> <span
class="irc-black">&lt;codemaestro&gt; I haven&#8217;t totally been following. Are the authors for or against modifying JavaScript object prototypes?</span></p><p><span
class="irc-date">[21:45]</span> <span
class="irc-black">&lt;Velochicdunord&gt; Thx codepo8.</span></p><p><span
class="irc-date">[21:45]</span> <span
class="irc-black">&lt;codepo8&gt; @HAWK well, blocking people out for not having it. You can rely on JS &#8211; if what you build is making the experience smoother. Basic functionality should always be a given. A link should point someplace, not fire a JavaScript that might be broken.</span></p><p><span
class="irc-date">[21:45]</span> <span
class="irc-black">&lt;HAWK&gt; Hi codemaestro &#8211; that hasn&#8217;t been covered. Let&#8217;s throw it to Ara</span></p><p><span
class="irc-date">[21:45]</span> <span
class="irc-black">&lt;Ara&gt; JoshySav: JavaScript is the de facto scripting language for browsers. It used to be that you could choose between Microsoft&#8217;s Visual Basic and JavaScript, but JavaScript won. There are efforts to introduce competing scripting languages (like Google&#8217;s Dart) but JavaScript is pretty much the only choice.</span></p><p><span
class="irc-date">[21:46]</span> <span
class="irc-black">&lt;JoshySav&gt; Ara Thanks :)</span></p><p><span
class="irc-date">[21:46]</span> <span
class="irc-black">&lt;JoshySav&gt; Its nice to talk to people with Brains ;)</span></p><p><span
class="irc-date">[21:47]</span> <span
class="irc-black">&lt;Ara&gt; codemaestro: It&#8217;s a touchy subject. Some libraries do it and some developers are comfortable doing it, but you have to remember that on the web, more often than not your code is going to coexist with other people&#8217;s, so if you get really fancy with native object prototypes, you might start running into conflicts with other people&#8217;s code.</span></p><p><span
class="irc-date">[21:47]</span> <span
class="irc-black">&lt;Ara&gt; JoshySav: I assume you mean the other guests. :)</span></p><p><span
class="irc-date">[21:47]</span> <span
class="irc-black">&lt;johnlacey&gt; @Ara &#8212; Given that Javascript can be disabled (as @Hawk pointed out earlier) are there certain things you should avoid using it for?</span></p><p><span
class="irc-date">[21:47]</span> <span
class="irc-black">&lt;HAWK&gt; I think he was talking about me Ara</span></p><p><span
class="irc-date">[21:47]</span> <span
class="irc-black">&lt;JoshySav&gt; :)</span></p><p><span
class="irc-date">[21:47]</span> <span
class="irc-black">&lt;Ara&gt; HAWK: :)</span></p><p><span
class="irc-date">[21:48]</span> <span
class="irc-black">&lt;JoshySav&gt; To be honest, How many people have JavaScript turned off?</span></p><p><span
class="irc-date">[21:48]</span> <span
class="irc-black">&lt;codemaestro&gt; Thanks Ara &#8212; so the answer is, &#8220;it depends.&#8221;</span></p><p><span
class="irc-date">[21:48]</span> <span
class="irc-black">&lt;HAWK&gt; Yeah, interesting question JoshySav. I (obviously) spend a lot of time on the SitePoint forums so my perspective is skewed &#8211; but there is a fairly large contingent of people over there that do&#8230;</span></p><p><span
class="irc-date">[21:48]</span> <span
class="irc-black">&lt;Ara&gt; johnlacey: That depends entirely on the site/app you&#8217;re building. If it needs to be 100% accessible, then you need to look into progressive enhancement, where the site will work with and without JavaScript. But not all sites and apps have that requirement, so you can get away with a purely JavaScript application. It&#8217;s a case by case thing.</span></p><p><span
class="irc-date">[21:49]</span> <span
class="irc-black">&lt;HAWK&gt; The accessibility guys</span></p><p><span
class="irc-date">[21:49]</span> <span
class="irc-black">&lt;codepo8&gt; Everybody has JavaScript turned off until the first script is loaded and executed. If something goes wrong there and your whole app relies on that, you lost a user.</span></p><p><span
class="irc-date">[21:50]</span> <span
class="irc-black">&lt;johnlacey&gt; There&#8217;s a whole lot of form validation in my life that relies on Javascript&#8230; but I guess I&#8217;ll have to have PHP fallbacks just in case. lol</span></p><p><span
class="irc-date">[21:50]</span> <span
class="irc-black">&lt;Velochicdunord&gt; Ara &#8211; any recommended resources (besides your book, of course) regarding best practices for Javascript implementation and use? Does your book cover this?</span></p><p><span
class="irc-date">[21:50]</span> <span
class="irc-black">&lt;ginader&gt; especially in mobile environments it more likely that a user fails to load js rather than having turned of js</span></p><p><span
class="irc-date">[21:51]</span> <span
class="irc-black">&lt;Ara&gt; johnlacey: As a rule of thumb, you should never rely on JavaScript as your only form of data validation. It should be used more as a convenience than a safeguard since people can not only turn off JavaScript but also mess with values and functions in the browser.</span></p><p><span
class="irc-date">[21:52]</span> <span
class="irc-black">&lt;codepo8&gt; ^ that. I have cURL and I will use it! </span></p><p><span
class="irc-date">[21:53]</span> <span
class="irc-black">&lt;codepo8&gt; The chrome download page was not working for half a day the other day because of a JS error: <a
href="http://icant.co.uk/talks/h5/pictures/jqueryeu/chrome-download-broken.png">http://icant.co.uk/talks/h5/pictures/jqueryeu/chrome-download-broken.png</a> &#8211; The big glaring mistake here was the &#8220;javascript:void(0)&#8221; link. These are crimes we should not commit in this day and age. </span></p><p><span
class="irc-date">[21:53]</span> <span
class="irc-black">&lt;Ramy&gt; is the book explaining JavaScript syntax and DOM and using it in browsers or going through now a days apps for mobile platforms ?</span></p><p><span
class="irc-date">[21:53]</span> <span
class="irc-black">&lt;HAWK&gt; I&#8217;m interested in Velochicdunord&#8217;s question: any recommended resources (besides your book, of course) regarding best practices for Javascript implementation and use?</span></p><p><span
class="irc-date">[21:53]</span> <span
class="irc-black">&lt;Ara&gt; Velochicdunord: I cover some best practices in the book but I don&#8217;t go in depth. There are several schools of thought on best JavaScript practices. Personally, I ascribe to the Douglas Crockford (<a
href="http://www.crockford.com/)">http://www.crockford.com/)</a> way of thinking. You&#8217;ll find a lot of defensive programming techniques in the jQuery community, like encapsulating your code in</span></p><p><span
class="irc-date">[21:53]</span> <span
class="irc-black">&lt;Ara&gt; an IIFE (Immediately Invoked Function Expression) where the values for &#8220;undefined&#8221; and &#8220;window&#8221; are reinitialized.</span></p><p><span
class="irc-date">[21:54]</span> <span
class="irc-black">&lt;Velochicdunord&gt; I just found Doug Crockford this February. Still much to dig through.</span></p><p><span
class="irc-date">[21:54]</span> <span
class="irc-black">&lt;codepo8&gt; You lost him before?</span></p><p><span
class="irc-date">[21:54]</span> <span
class="irc-black">&lt;Ara&gt; More specific link to Crockford on JavaScript: <a
href="http://javascript.crockford.com/">http://javascript.crockford.com/</a></span></p><p><span
class="irc-date">[21:55]</span> <span
class="irc-black">&lt;Ara&gt; Ramy: The book explains JS syntax and the DOM but doesn&#8217;t explicitly deal with Mobile environments.</span></p><p><span
class="irc-date">[21:55]</span> <span
class="irc-black">&lt;Velochicdunord&gt; codepo8 :) &#8211; no &#8211; as a noob, hadn&#8217;t heard of him before. Am about halfway through his lecture series on the history of Javascript.</span></p><p><span
class="irc-date">[21:56]</span> <span
class="irc-brick">* mattevans slaps MalCurtis around a bit with a large trout</span></p><p><span
class="irc-date">[21:56]</span> <span
class="irc-black">&lt;HAWK&gt; Ah &#8211; the old trout slap</span></p><p><span
class="irc-date">[21:56]</span> <span
class="irc-black">&lt;mattevans&gt; :-)</span></p><p><span
class="irc-date">[21:56]</span> <span
class="irc-black">&lt;johnlacey&gt; lol. I hadn&#8217;t seen the ol&#8217; trout slap in forever.</span></p><p><span
class="irc-date">[21:57]</span> <span
class="irc-black">&lt;Ara&gt; Velochicdunord: He&#8217;s the author of JSLint (<a
href="http://www.jsliint.com)." class="broken_link">http://www.jsliint.com).</a> It&#8217;s a JavaScript linting tool that helps you find errors in your code. It&#8217;s in essence a distillation of the Crockford school of thought when it comes to code style. Some people differ with him and forked JSLint and created JSHint (<a
href="http://www.jshint.com)" class="broken_link">http://www.jshint.com)</a> which does the same thing </span></p><p><span
class="irc-date">[21:57]</span> <span
class="irc-black">&lt;Ara&gt; but is billed as being more friendly.</span></p><p><span
class="irc-date">[21:58]</span> <span
class="irc-black">&lt;HAWK&gt; Now that things are a bit quieter &#8211; has anyone asked a question that hasn&#8217;t been answered yet?</span></p><p><span
class="irc-date">[21:58]</span> <span
class="irc-black">&lt;ralphm&gt; I&#8217;ve read a number of JS books, but when I&#8217;m on my own, I do find it hard to &#8220;think&#8221; in JavaScript. If something doesn&#8217;t work, it&#8217;s hard to know where to turn. Often JSLint and JSHint report that the code is fine, yet it doesn&#8217;t work. So then the question is, &#8220;how do I talk to the browser?&#8221; Any tips on how to take the next step, other than googling?</span></p><p><span
class="irc-date">[21:58]</span> <span
class="irc-black">&lt;Velochicdunord&gt; Merci &#8211; yeah, found the JSLInt &amp; Hint business. :)</span></p><p><span
class="irc-date">[21:58]</span> <span
class="irc-black">&lt;codepo8&gt; Having worked with Douglas for a while was very eye-opening. He knows his stuff, but can be very dogmatic about things. I like that. If you haven&#8217;t annoyed anyone in your life then you probably had no opinion or new thought.</span></p><p><span
class="irc-date">[21:59]</span> <span
class="irc-black">&lt;Ara&gt; ralphm: Learn to love the debugger. I&#8217;ve found that if you set breakpoints in your code then step through it, keeping a close eye on the values being passed around, you&#8217;ll often find what&#8217;s going wrong pretty quick.</span></p><p><span
class="irc-date">[22:00]</span> <span
class="irc-black">&lt;codepo8&gt; @ralphm the developer tools in browsers will tell you in a lot of cases what is wrong. JSLINT only tells you glaring syntax problems. For example a failure of interaction or data coming in in the wrong format is not caught by it. That&#8217;s where the browser&#8217;s error console helps you. </span></p><p><span
class="irc-date">[22:00]</span> <span
class="irc-black">&lt;Ara&gt; ralphm: All major browsers have built in debuggers now. I actually cover how to activate the browser&#8217;s console to get access to the debugger in the first chapter of the book: <a
href="https://learnable.com/books/jsjavascript1/online/ch01.html#d5e162">https://learnable.com/books/jsjavascript1/online/ch01.html#d5e162</a></span></p><p><span
class="irc-date">[22:00]</span> <span
class="irc-black">&lt;Barney&gt; to annoy someone is easily done&#8230; just say &#8220;MS Rulz!&#8221;</span></p><p><span
class="irc-date">[22:00]</span> <span
class="irc-black">&lt;Velochicdunord&gt; Barney:)</span></p><p><span
class="irc-date">[22:00]</span> <span
class="irc-black">&lt;johnlacey&gt; I kind of wish I had more questions&#8230; but I am waiting for the coffee to reach my brain. I have however downloaded the book and look forward to reading it.</span></p><p><span
class="irc-date">[22:01]</span> <span
class="irc-black">&lt;codepo8&gt; also just playing with the console is fun. Type navigator. and see all the things the browser offers you and play with them. Many a time you find a feature you never heard of. </span></p><p><span
class="irc-date">[22:01]</span> <span
class="irc-black">&lt;ralphm&gt; Haven&#8217;t really got my head around debugging, other than using console.log() at various point to see where the code is up to. Problem is, if things are going wrong, it doesn&#8217;t say what else to try, and that&#8217;s where I get a bit stuck.</span></p><p><span
class="irc-date">[22:01]</span> <span
class="irc-black">&lt;Barney&gt; &#8220;..takes well deserved bow!&#8221;</span></p><p><span
class="irc-date">[22:01]</span> <span
class="irc-black">&lt;Ara&gt; johnlacey: feel free to hit me up with more questions any time. I&#8217;m @ara_p on Twitter</span></p><p><span
class="irc-date">[22:01]</span> <span
class="irc-black">&lt;Ara&gt; That goes for anyone else too. I&#8217;m always free to answer questions. ^^</span></p><p><span
class="irc-date">[22:01]</span> <span
class="irc-black">&lt;johnlacey&gt; @Ara &#8212; Thanks!</span></p><p><span
class="irc-date">[22:02]</span> <span
class="irc-black">&lt;codepo8&gt; then go to <a
href="https://developer.mozilla.org/en-US/docs/JavaScript">https://developer.mozilla.org/en-US/docs/JavaScript</a> and learn how and why these things happen. An incredible resource maintained by a hardworking staff of experts who should be sleeping right now.</span></p><p><span
class="irc-date">[22:02]</span> <span
class="irc-black">&lt;Ara&gt; and by free I mean &#8220;happy to.&#8221; :)</span></p><p><span
class="irc-date">[22:02]</span> <span
class="irc-black">&lt;JC&gt; I have a question: If one knows jQuery and basic Js syntax, what is the best way to get to really know Javascript at a pro level?</span></p><p><span
class="irc-date">[22:02]</span> <span
class="irc-black">&lt;codepo8&gt; also <a
href="http://www.webplatform.org/">http://www.webplatform.org/</a> is the new up and coming one-stop-shop for curated web content rather than hearsay you get on w3schools or stackoverflow. </span></p><p><span
class="irc-date">[22:02]</span> <span
class="irc-black">&lt;Velochicdunord&gt; I second JC&#8217;s question.</span></p><p><span
class="irc-date">[22:03]</span> <span
class="irc-black">&lt;codepo8&gt; And of course sitepoint :)</span></p><p><span
class="irc-date">[22:03]</span> <span
class="irc-black">&lt;Ara&gt; ralphm: I guess I need to write a blog post on debugging. :)</span></p><p><span
class="irc-date">[22:03]</span> <span
class="irc-black">&lt;codepo8&gt; @JC dig into the source of some libraries and tools. Adobe&#8217;s Brackets is a very hot and amazingly well crafted project <a
href="http://brackets.io/">http://brackets.io/</a></span></p><p><span
class="irc-date">[22:04]</span> <span
class="irc-black">&lt;Ara&gt; JC: open up the jQuery source code and look at what they&#8217;re doing. That will give you a lot of pro-level insight. Likewise with lots of projects on GitHub. Also, in your free time, try and code the craziest things you can think of.</span></p><p><span
class="irc-date">[22:04]</span> <span
class="irc-black">&lt;ralphm&gt; @Ara That would be great. :-) </span></p><p><span
class="irc-date">[22:04]</span> <span
class="irc-black">&lt;Ara&gt; Velochicdunord ^^</span></p><p><span
class="irc-date">[22:04]</span> <span
class="irc-black">&lt;Barney&gt; SIMPLY JAVASCRIPT BY KEVIN YANK &amp; CAMERON ADAMS I just finished &#8212; good book thanks SitePoint</span></p><p><span
class="irc-date">[22:04]</span> <span
class="irc-black">&lt;Ara&gt; Barney +1</span></p><p><span
class="irc-date">[22:04]</span> <span
class="irc-black">&lt;codepo8&gt; first time I see SIMPLY screamed</span></p><p><span
class="irc-date">[22:04]</span> <span
class="irc-black">&lt;Velochicdunord&gt; following a mess of libraries on GitHub</span></p><p><span
class="irc-date">[22:04]</span> <span
class="irc-black">&lt;HAWK&gt; Hehe, glad to be of service Barney</span></p><p><span
class="irc-date">[22:05]</span> <span
class="irc-black">&lt;HAWK&gt; Welcome NickY &#8211; feel free to jump in with questions (if you have any) at any time</span></p><p><span
class="irc-date">[22:05]</span> <span
class="irc-black">&lt;Ara&gt; Velochicdunord &amp; JC: You&#8217;re probably better off following the more popular open source projects as they&#8217;ve got a lot more eyes scrutinizing the code.</span></p><p><span
class="irc-date">[22:05]</span> <span
class="irc-black">&lt;Barney&gt; no prob, HAWK &#8211; I have some 20 books from you guys and did like 5 classes &#8212; I brag up siteP and Lean&#8230; all the time</span></p><p><span
class="irc-date">[22:05]</span> <span
class="irc-black">&lt;Velochicdunord&gt; Any suggestions for open source to follow?</span></p><p><span
class="irc-date">[22:05]</span> <span
class="irc-black">&lt;Ara&gt; That&#8217;s the great thing about open source projects, you can&#8217;t get away with junk&#8211;at least not if your code is popular enough to have lots of people looking at it. :)</span></p><p><span
class="irc-date">[22:05]</span> <span
class="irc-black">&lt;Barney&gt; &#8230; is bucking for a free month!&#8221; *smiles*</span></p><p><span
class="irc-date">[22:06]</span> <span
class="irc-black">&lt;Barney&gt; the WP bookis here are great open source guides&#8230;</span></p><p><span
class="irc-date">[22:06]</span> <span
class="irc-black">&lt;codepo8&gt; yes, being open means your successes and your failures speak for you </span></p><p><span
class="irc-date">[22:06]</span> <span
class="irc-black">&lt;Velochicdunord&gt; Own a few. :)</span></p><p><span
class="irc-date">[22:06]</span> <span
class="irc-black">&lt;HAWK&gt; Ah Capt_Snickle_Fritz &#8211; nice to see you again</span></p><p><span
class="irc-date">[22:07]</span> <span
class="irc-black">&lt;Ara&gt; Velochicdunord: jQuery (<a
href="https://github.com/jquery/jquery)," class="broken_link">https://github.com/jquery/jquery),</a> YUI (<a
href="https://github.com/yui/yui3)," class="broken_link">https://github.com/yui/yui3),</a> Backbone (<a
href="https://github.com/documentcloud/backbone)," class="broken_link">https://github.com/documentcloud/backbone),</a> Underscore (<a
href="https://github.com/documentcloud/underscore)" class="broken_link">https://github.com/documentcloud/underscore)</a></span></p><p><span
class="irc-date">[22:07]</span> <span
class="irc-black">&lt;Velochicdunord&gt; Thx</span></p><p><span
class="irc-date">[22:07]</span> <span
class="irc-black">&lt;Capt_Snickle_Fritz&gt; Likewise HAWK</span></p><p><span
class="irc-date">[22:07]</span> <span
class="irc-black">&lt;Barney&gt; Vel, you got Anthology books?</span></p><p><span
class="irc-date">[22:08]</span> <span
class="irc-black">&lt;Ara&gt; I guess &#8220;come at me, bro!&#8221; isn&#8217;t the best way to ask people for more questions, huh? ;)</span></p><p><span
class="irc-date">[22:08]</span> <span
class="irc-black">&lt;HAWK&gt; Hehe, love it Ara</span></p><p><span
class="irc-date">[22:08]</span> <span
class="irc-black">&lt;HAWK&gt; But yeah &#8211; if anyone has a question, jump in now while there&#8217;s a space!</span></p><p><span
class="irc-date">[22:08]</span> <span
class="irc-black">&lt;Ara&gt; This is fun.</span></p><p><span
class="irc-date">[22:08]</span> <span
class="irc-black">&lt;HAWK&gt; You&#8217;re owning it. Nice work.</span></p><p><span
class="irc-date">[22:09]</span> <span
class="irc-black">&lt;Ara&gt; Thanks to the guests. Great questions, folks.</span></p><p><span
class="irc-date">[22:09]</span> <span
class="irc-black">&lt;codepo8&gt; why is the following line not a JavaScript error:</span></p><p><span
class="irc-date">[22:09]</span> <span
class="irc-black">&lt;codepo8&gt; <a
href="http://vanillawebdiet.com " class="broken_link">http://vanillawebdiet.com </a></span></p><p><span
class="irc-date">[22:09]</span> <span
class="irc-black">&lt;HAWK&gt; Hi to those of you that have just joined &#8211; jump in at any time if you have a question. You can check the full transcript later today on SitePoint.</span></p><p><span
class="irc-date">[22:09]</span> <span
class="irc-black">&lt;Ara&gt; codepo8: trick question, because there&#8217;s no JavaScript in it. ;)</span></p><p><span
class="irc-date">[22:09]</span> <span
class="irc-black">&lt;codepo8&gt; no</span></p><p><span
class="irc-date">[22:10]</span> <span
class="irc-black">&lt;HAWK&gt; You can also check out Ara&#8217;s book here <a
href="https://learnable.com/books/jsjavascript1">https://learnable.com/books/jsjavascript1</a></span></p><p><span
class="irc-date">[22:10]</span> <span
class="irc-black">&lt;codepo8&gt; try it in a script, it doesn&#8217;t fire an error</span></p><p><span
class="irc-date">[22:10]</span> <span
class="irc-black">&lt;Ara&gt; codepo8: I wonder if the IRC client filtered out the code then &#8217;cause all I saw was the vanillawebdiet.com URL</span></p><p><span
class="irc-date">[22:10]</span> <span
class="irc-black">&lt;Ara&gt; maybe paste it in jsfiddle?</span></p><p><span
class="irc-date">[22:10]</span> <span
class="irc-black">&lt;Velochicdunord&gt; No &#8211; WP Novice to Ninja was a bit of a disappointment &#8211; not enough substance. Held off purchasing additional SitePoint books after that.</span></p><p><span
class="irc-date">[22:11]</span> <span
class="irc-black">&lt;HAWK&gt; The IRC client shouldn&#8217;t do that &#8211; it should paste it as a gist</span></p><p><span
class="irc-date">[22:11]</span> <span
class="irc-black">&lt;ralphm&gt; OK, I might as well ask. No matter what I read (books and online) I can&#8217;t find a simple, conceptual answer to what a &#8220;prototype&#8221; is. E.g. Array.prototype. Can anyone offer a potted explanation?</span></p><p><span
class="irc-date">[22:11]</span> <span
class="irc-black">&lt;Ara&gt; Velochicdunord: You can always read the first chapter for Jump Start JavaScript here, if you want a preview: <a
href="https://learnable.com/books/jsjavascript1/online/ch01.html">https://learnable.com/books/jsjavascript1/online/ch01.html</a></span></p><p><span
class="irc-date">[22:11]</span> <span
class="irc-black">&lt;Velochicdunord&gt; Second ralph&#8217;s question!</span></p><p><span
class="irc-date">[22:11]</span> <span
class="irc-black">&lt;codepo8&gt; <a
href="http://jsfiddle.net/jp5PZ/">http://jsfiddle.net/jp5PZ/</a></span></p><p><span
class="irc-date">[22:11]</span> <span
class="irc-black">&lt;Velochicdunord&gt; Thx, Ara.</span></p><p><span
class="irc-date">[22:13]</span> <span
class="irc-black">&lt;HAWK&gt; I&#8217;m just going to jump in to let you know that if you want reminders of future sessions like this, sign up for the mailing list here <a
href="http://www.facebook.com/sitepoint/app_115462065200508">http://www.facebook.com/sitepoint/app_115462065200508</a></span></p><p><span
class="irc-date">[22:13]</span> <span
class="irc-black">&lt;codepo8&gt; this article is very good on prototype: <a
href="http://dailyjs.com/2012/05/21/js101-prototype/ " class="broken_link">http://dailyjs.com/2012/05/21/js101-prototype/ </a></span></p><p><span
class="irc-date">[22:14]</span> <span
class="irc-black">&lt;ralphm&gt; Thanks codepo8. Will check it out.</span></p><p><span
class="irc-date">[22:14]</span> <span
class="irc-black">&lt;Ara&gt; ralphm &amp; Velochicdunord: So, JavaScript&#8217;s inheritance model is prototypal. Basically what it means is, everything&#8217;s an object and objects inherit from objects so when you inherit from an object, you&#8217;re inheriting its prototype object. (Dang, I think that wasn&#8217;t clear)</span></p><p><span
class="irc-date">[22:14]</span> <span
class="irc-black">&lt;Velochicdunord&gt; No &#8211; that&#8217;s good.</span></p><p><span
class="irc-date">[22:14]</span> <span
class="irc-black">&lt;HAWK&gt; Hey Jess</span></p><p><span
class="irc-date">[22:14]</span> <span
class="irc-black">&lt;JC&gt; Thank you for your answers</span></p><p><span
class="irc-date">[22:15]</span> <span
class="irc-black">&lt;codepo8&gt; Ara as to my error &#8211; pause filler &#8211; a URL like this in JS is actually a JavaScript label followed by a comment, hence no syntax error. Labels are very much not used anymore.</span></p><p><span
class="irc-date">[22:15]</span> <span
class="irc-black">&lt;scruggs&gt; Would you classify that as a limitation of the JS language itself? After all, it is only recently that tools like jQuery and Node.js has sprung popularity in the JS community again</span></p><p><span
class="irc-date">[22:15]</span> <span
class="irc-black">&lt;jessirwin&gt; Hi HAWK</span></p><p><span
class="irc-date">[22:15]</span> <span
class="irc-black">&lt;Ara&gt; codepo8: It&#8217;s odd, because in the Chrome console I get the following error: SyntaxError: Unexpected token }</span></p><p><span
class="irc-date">[22:16]</span> <span
class="irc-black">&lt;Ara&gt; JC: my pleasure!</span></p><p><span
class="irc-date">[22:16]</span> <span
class="irc-black">&lt;Ara&gt; scruggs: I&#8217;m not sure I follow. What would be classified as a potential limitation? (Prototypes?)</span></p><p><span
class="irc-date">[22:17]</span> <span
class="irc-black">&lt;Ramy&gt; HAWK the mail reminder is good but i wish there is another reminder for facebook beside posts like an event</span></p><p><span
class="irc-date">[22:17]</span> <span
class="irc-black">&lt;codepo8&gt; scruggs different audiences I&#8217;d say. jQuery lowered the barrier a lot and is focused on DOM access and interface element creation like widgets. It made it damn easy to reach things and change things in a document. Node got a new audience as it moved JS to the server and made it unhindered by the DOM. The main boost for JS however was HTML5 and Flas</span></p><p><span
class="irc-date">[22:17]</span> <span
class="irc-black">&lt;codepo8&gt; h being less reliable as it wasn&#8217;t supported on the hottest and newest devices (iOS)</span></p><p><span
class="irc-date">[22:17]</span> <span
class="irc-black">&lt;HAWK&gt; Very good point Ramy &#8211; I can totally post them as events. </span></p><p><span
class="irc-date">[22:18]</span> <span
class="irc-black">&lt;Barney&gt; Thanks for letting me join, see you all on the flipside&#8230;</span></p><p><span
class="irc-date">[22:18]</span> <span
class="irc-black">&lt;Ara&gt; Cheers, Barney!</span></p><p><span
class="irc-date">[22:19]</span> <span
class="irc-black">&lt;codepo8&gt; the unexpected token is from jsfiddle&#8217;s wrapper around it.</span></p><p><span
class="irc-date">[22:19]</span> <span
class="irc-black">&lt;NickY&gt; Any good books out there that focus on using JavaScript for games?</span></p><p><span
class="irc-date">[22:19]</span> <span
class="irc-black">&lt;Ara&gt; codepo8: I didn&#8217;t get the error in jsfiddle, i got it directly in the chrome console.</span></p><p><span
class="irc-date">[22:19]</span> <span
class="irc-black">&lt;scruggs&gt; okay&#8230;maybe it&#8217;s not a limitation. I guess I am struggling to jump into the JS side of things yet&#8230;inheritance from what I have seen has been painful in many JS applications. For example, jumping into frameworks like Knockout.js and Backbone.js&#8230;it seems like the real trick is learning the frameworks and their limitations and what not</span></p><p><span
class="irc-date">[22:21]</span> <span
class="irc-black">&lt;codepo8&gt; if you want to stick to the mindset of class-based languages with full inheritance and mutation and the rest it is probably a good idea to stick to frameworks like the ones you mentioned. JavaScript will not change any time soon reliably across all the software that understands it so the attempts of &#8220;changing JavaScript so that it is more like lang</span></p><p><span
class="irc-date">[22:21]</span> <span
class="irc-black">&lt;codepo8&gt; uage $x&#8221; are pretty futile. </span></p><p><span
class="irc-date">[22:22]</span> <span
class="irc-black">&lt;codepo8&gt; That said, TypeScript and Dart allow you to do these and convert to JavaScript for you. </span></p><p><span
class="irc-date">[22:22]</span> <span
class="irc-black">&lt;NickY&gt; I agree with you Scruggs. You do have to learn the framework. You could build applications using jquery with almost no knowledge of js itself</span></p><p><span
class="irc-date">[22:22]</span> <span
class="irc-black">&lt;Ara&gt; scruggs: More often than not you won&#8217;t need to know inheritance to do powerful things in JavaScript. But knowing it can help you take your code to another level. That said, it isn&#8217;t always necessary. You are right though that in the realm of frameworks, it&#8217;s more about knowing their API/syntax than it is about knowing JavaScript because you&#8217;re work</span></p><p><span
class="irc-date">[22:22]</span> <span
class="irc-black">&lt;Ara&gt; ing on an entirely different level at that point. You&#8217;re kind of abstracted away from the nuts and bolts of the language and are working with a framework&#8217;s API.</span></p><p><span
class="irc-date">[22:23]</span> <span
class="irc-black">&lt;codepo8&gt; NickY of course that comes at the cost of being reliant on a framework. If you go to town on a document with heavy jQuery that is not really taking care of caching and re-using things it accesses you&#8217;ll be very disappointed when you want to ship your app to mobile devices.</span></p><p><span
class="irc-date">[22:24]</span> <span
class="irc-black">&lt;codepo8&gt; (disclaimer: I work with a focus on FirefoxOS devices right now &#8211; low spec smartphones for a new market, so every event handler and every DOM access hurts) :)</span></p><p><span
class="irc-date">[22:25]</span> <span
class="irc-black">&lt;Ara&gt; scruggs &amp; NickY: regardless of the library or framework though, you still need to have a basic understanding of variables, variable types, logic operators, arrays, objects, functions&#8230; you still need to work with those things. jQuery gives you helpers to access DOM elements and iterate over objects and Backbone lets you do some great MVC stuff, bu</span></p><p><span
class="irc-date">[22:25]</span> <span
class="irc-black">&lt;Ara&gt; t in the end you&#8217;re still writing JavaScript and passing around values and manipulating them. So you still need to know JS.</span></p><p><span
class="irc-date">[22:25]</span> <span
class="irc-black">&lt;HAWK&gt; 5 mins to go people. If you&#8217;re new to JavaScript and are worried about sounding dumb but have a question, please do ask.</span></p><p><span
class="irc-date">[22:25]</span> <span
class="irc-black">&lt;HAWK&gt; No such thing as a dumb question when you&#8217;re learning</span></p><p><span
class="irc-date">[22:25]</span> <span
class="irc-black">&lt;Ara&gt; There&#8217;s no such thing as a dumb question :)</span></p><p><span
class="irc-date">[22:26]</span> <span
class="irc-black">&lt;Ara&gt; HAWK *boom!*</span></p><p><span
class="irc-date">[22:26]</span> <span
class="irc-black">&lt;HAWK&gt; hehe indeed</span></p><p><span
class="irc-date">[22:26]</span> <span
class="irc-black">&lt;BluePandaStudios&gt; codepo8 / Ara: I&#8217;m late to the talk, so I apologize if this was covered, but are there frameworks you would recommend that take mobile access into account?</span></p><p><span
class="irc-date">[22:26]</span> <span
class="irc-black">&lt;NickY&gt; That is a good point, but there are many functions in jquery that you still won&#8217;t even need to know that</span></p><p><span
class="irc-date">[22:27]</span> <span
class="irc-black">&lt;johnlacey&gt; @HAWK I am pretty sure I have angered the techno-gods today&#8230; but I am on the Facebook page for email notifications for Talk with the experts&#8230; and should there be a button to click after I enter details? Because there isn&#8217;t. lol</span></p><p><span
class="irc-date">[22:27]</span> <span
class="irc-black">&lt;codemaestro&gt; Oh yeah. How many users are actually using ExtJS/Sencha Touch vs. jQuery Mobile?</span></p><p><span
class="irc-date">[22:27]</span> <span
class="irc-black">&lt;scruggs&gt; ara&#8230;I think the hardest part is trying to learn how the language cooperates at times lol. I am a C# programmer by trade, but I am trying to get a strong foothold into the JS community, so I have been trying to learn all I can about knockout.js, backbone, and trying to build things with node.js</span></p><p><span
class="irc-date">[22:27]</span> <span
class="irc-black">&lt;Ara&gt; BluePandaStudios: off the top of my head I know that jQuery has a mobile component and YUI has mobile built into it (as well as modules you can use that are mobile specific like touch controls)</span></p><p><span
class="irc-date">[22:28]</span> <span
class="irc-black">&lt;BluePandaStudios&gt; Also, any feedback on libraries that you feel are &#8220;_must checkout_&#8221; (besides jQuery&#8230;)?</span></p><p><span
class="irc-date">[22:28]</span> <span
class="irc-black">&lt;NickY&gt; take for example $(element).is(&#8216;:hidden&#8217;) &#8211; no need to understand any core js fundamentals there jquery does it all for you</span></p><p><span
class="irc-date">[22:29]</span> <span
class="irc-black">&lt;NickY&gt; i love jquery but sometimes I think it makes us lazy. </span></p><p><span
class="irc-date">[22:29]</span> <span
class="irc-black">&lt;Ara&gt; scruggs: I think it&#8217;s great that you&#8217;re learning those frameworks. But I think you&#8217;d be well served to spend some time poking around in native JavaScript, just to get a better grasp of how JS deals with things like loose typing and type coercion, or variable scoping. Those things become important as your programs get more complex.</span></p><p><span
class="irc-date">[22:29]</span> <span
class="irc-black">&lt;HAWK&gt; Oh johnlacey, you&#8217;ve broken it.</span></p><p><span
class="irc-date">[22:29]</span> <span
class="irc-black">&lt;codepo8&gt; BluePandaStudios sencha touch is good, jQuery mobile needs some brushing up, Zepto.js is a very lightweight one (for the moment). A lot is dependent on what you do. Sometimes just something like hammer.js is all you want (this one makes touch interaction simple)</span></p><p><span
class="irc-date">[22:29]</span> <span
class="irc-black">&lt;HAWK&gt; Ok, I have &#8211; sorry! Fixing now.</span></p><p><span
class="irc-date">[22:29]</span> <span
class="irc-black">&lt;johnlacey&gt; @HAWK &#8212; So it would seem. lol</span></p><p><span
class="irc-date">[22:30]</span> <span
class="irc-black">&lt;scruggs&gt; Ara: I will definitely get back to the basics of JS again. Last time I used native JavaScript trying to traverse the DOM was a painful experience! :)</span></p><p><span
class="irc-date">[22:31]</span> <span
class="irc-black">&lt;Ara&gt; NickY: jQuery is definitely more convenient than writing out what it&#8217;s doing under the hood longhand every time. That said, understanding what it&#8217;s doing can be helpful. Especially if you&#8217;re going to be coding web applications that do a lot of heavy lifting in the client but not necessary on the DOM layer.</span></p><p><span
class="irc-date">[22:31]</span> <span
class="irc-black">&lt;HAWK&gt; Check back in an hour johnlacey &#8211; I&#8217;ll sort it straight after this session</span></p><p><span
class="irc-date">[22:31]</span> <span
class="irc-black">&lt;codepo8&gt; NickY I&#8217;d argue there that if you don&#8217;t know when some element of your YUI is hidden and you need to ask the browser to tell you that (which means it needs to access the DOM and try it out) then you have not planned your UI right. The browser is there to display, not to retain display logic.</span></p><p><span
class="irc-date">[22:31]</span> <span
class="irc-black">&lt;scruggs&gt; Are there any nifty JS templating tools available?</span></p><p><span
class="irc-date">[22:31]</span> <span
class="irc-black">&lt;Ara&gt; NickY: For example, if you were to write a JS based spreadsheet like the one in Google Docs. There&#8217;s a ton of non-library JavaScript action going on behind the scenes, I&#8217;m sure. When it comes time to render the stuff, they probably use a framework.</span></p><p><span
class="irc-date">[22:32]</span> <span
class="irc-black">&lt;HAWK&gt; Whoa &#8211; the time has flown. We&#8217;re going to need to start wrapping things up so that I can cut Ara free</span></p><p><span
class="irc-date">[22:32]</span> <span
class="irc-black">&lt;codepo8&gt; scruggs you&#8217;d be surprised how many times you don&#8217;t need to traverse the  DOM if you add a CSS class to a parent element and keep this logic in your CSS. </span></p><p><span
class="irc-date">[22:32]</span> <span
class="irc-black">&lt;HAWK&gt; I&#8217;m going to call no more new questions, but I won&#8217;t be closing the room so you&#8217;re free to hang around and chat as long as you like</span></p><p><span
class="irc-date">[22:32]</span> <span
class="irc-black">&lt;codepo8&gt; scruggs yes &#8211; mustache.js and handlebars.js</span></p><p><span
class="irc-date">[22:32]</span> <span
class="irc-black">&lt;johnlacey&gt; Thanks @Ara @Hawk</span></p><p><span
class="irc-date">[22:32]</span> <span
class="irc-black">&lt;HAWK&gt; Don&#8217;t forget to check out Ara&#8217;s new book <a
href="https://learnable.com/books/jsjavascript1">https://learnable.com/books/jsjavascript1</a></span></p><p><span
class="irc-date">[22:33]</span> <span
class="irc-black">&lt;Ara&gt; scruggs: Definitely. You&#8217;ve got Mustache JS (<a
href="https://github.com/janl/mustache.js/)," class="broken_link">https://github.com/janl/mustache.js/),</a> Handlebars JS (<a
href="http://handlebarsjs.com/)" class="broken_link">http://handlebarsjs.com/)</a> and even Underscore has a templating system (<a
href="http://underscorejs.org/#template)">http://underscorejs.org/#template)</a></span></p><p><span
class="irc-date">[22:33]</span> <span
class="irc-black">&lt;HAWK&gt; And same time next week we&#8217;re running a live CSS codefix session with Alex Walker</span></p><p><span
class="irc-date">[22:33]</span> <span
class="irc-black">&lt;codemaestro&gt; This has been a real ADHD experience.</span></p><p><span
class="irc-date">[22:33]</span> <span
class="irc-black">&lt;Ara&gt; scruggs: just off the top of my head</span></p><p><span
class="irc-date">[22:33]</span> <span
class="irc-black">&lt;Ara&gt; codemaestro: tell me about it! :D</span></p><p><span
class="irc-date">[22:33]</span> <span
class="irc-black">&lt;NickY&gt; I agree ara, I guess all I was really trying to say is that I believe everyone should get a strong understanding of js before turning to libraries</span></p><p><span
class="irc-date">[22:33]</span> <span
class="irc-black">&lt;Ara&gt; I hope I didn&#8217;t miss anyone&#8217;s questions. Please repeat them if I did.</span></p><p><span
class="irc-date">[22:34]</span> <span
class="irc-black">&lt;codemaestro&gt; NickY or go into the libraries with a desire to find the underlying behaviours</span></p><p><span
class="irc-date">[22:34]</span> <span
class="irc-black">&lt;HAWK&gt; I want to say a huge thanks to Ara &#8211; you&#8217;ve been an absolute legend today, handling the hoards alone</span></p><p><span
class="irc-date">[22:34]</span> <span
class="irc-black">&lt;codemaestro&gt; I had a problem with $(elem).text(&#8221;) not producing the same result in two different point versions of Chrome.</span></p><p><span
class="irc-date">[22:34]</span> <span
class="irc-black">&lt;Ara&gt; NickY: I agree. Although over the years, the hardcore engineer in me has given way a little to the business dude in me who says that sometimes, to get the job done, you can just go the route of not having to know everything. (Shhhh, don&#8217;t tell anyone I said that.) ;)</span></p><p><span
class="irc-date">[22:34]</span> <span
class="irc-black">&lt;HAWK&gt; Much appreciated</span></p><p><span
class="irc-date">[22:34]</span> <span
class="irc-black">&lt;codemaestro&gt; @ara LOL</span></p><p><span
class="irc-date">[22:34]</span> <span
class="irc-black">&lt;Ara&gt; HAWK: You&#8217;re too kind. :)</span></p><p><span
class="irc-date">[22:35]</span> <span
class="irc-black">&lt;NickY&gt; Ara lol yes I have been getting to that point. I blame freelancing:)</span></p><p><span
class="irc-date">[22:35]</span> <span
class="irc-black">&lt;BluePandaStudios&gt; HAWK, thanks for the talk, great time!</span></p><p><span
class="irc-date">[22:36]</span> <span
class="irc-black">&lt;scruggs&gt; Thanks. I am pleased with the suggestions and that nudge forward to continue learning more about the basics of JS and the technologies that incorporate it!</span></p><p><span
class="irc-date">[22:36]</span> <span
class="irc-black">&lt;Ara&gt; codemaestro: Yeah, i&#8217;m not sure what text() uses under the hood, but it could be that they didn&#8217;t account for changes from one Chrome release to another.</span></p><p><span
class="irc-date">[22:36]</span> <span
class="irc-black">&lt;NickY&gt; HAWK &#8211; is there a way to get alerts without going to Facebook?</span></p><p><span
class="irc-date">[22:36]</span> <span
class="irc-black">&lt;Ara&gt; codemaestro: I know that there are differences between IE and the rest of the browsers when it comes to innerText and textContent, so it could be something like that.</span></p><p><span
class="irc-date">[22:37]</span> <span
class="irc-black">&lt;HAWK&gt; NickY not at the moment, but you don&#8217;t need to have a Facebook account to use that form</span></p><p><span
class="irc-date">[22:37]</span> <span
class="irc-black">&lt;NickY&gt; Oh ok sweet I will do that then</span></p><p><span
class="irc-date">[22:37]</span> <span
class="irc-black">&lt;codemaestro&gt; true. eventually i discovered through trial/error/much googleing that the element needed the hasLayout property or something to be set.</span></p><p><span
class="irc-date">[22:38]</span> <span
class="irc-black">&lt;NickY&gt; thanks to ara, hawk, and everyone. This was fun.</span></p><p><span
class="irc-date">[22:38]</span> <span
class="irc-black">&lt;codemaestro&gt; I got a few more library names to scope out when I have time.</span></p><p><span
class="irc-date">[22:39]</span> <span
class="irc-black">&lt;Ara&gt; codemaestro Ahh.. the legendary hasLayout ;)</span></p><div
class='after-content-widget-1'><div
id="sitepointcontextualcontentmanagerwidget-5" class="widget widget_sitepointcontextualcontentmanagerwidget"><style>#targettedEOF { width: 99%; font-family: "Open Sans", Helvetica, Arial, sans-serif; border-radius: 4px; border: 1px dotted #47B4DC; }
#targettedEOF .targettedEOFcol { float: left; padding: 20px; }
#targettedEOF .targettedEOFbtn { clear: both; padding: 0; }
#targettedEOF h2 { margin-top: 10px; }
#targettedEOF .sptolbCTA { border: 0 none; border-bottom: 2px solid #85bb41; background-color: #91c352; color: white; margin: 0; padding: 1em 1em; border-radius: 4px; vertical-align: middle; text-align: center; font-weight: 700; font-size: 17px; display: inline-block; line-height: 0; text-shadow: -1px -1px 1px rgba(0,0,0,0.2); cursor: pointer; text-decoration: none;
}
#targettedEOF .sptolbCTA:hover { color: white; }
#targettedEOF .targettedEOFbtn p { padding: 0; margin: 0; }
.cat_javascript #targettedEOF h2, .cat_cloudspring #targettedEOF h2 { font-size: 1.267em; line-height: 1.158em; margin: 1.737em 0 0.579em 0; font-weight: bold; color: #0071D8; }
.cat_javascript #targettedEOF, .cat_cloudspring #targettedEOF { font-size: 1.5em; line-height: 1.467em; width: 100%; }
.cat_javascript #targettedEOF ul, .cat_cloudspring #targettedEOF ul { list-style: square; margin: 0 0 1.467em 1.467em; }</style><div
id="targettedEOF"><div
class="targettedEOFcol"> <a
href="https://learnable.com/books/jsjavascript1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=UltimateJavaScriptBundle"><img
src="https://learnable-images.s3.amazonaws.com/books/responsive1_medium.jpg" width="145"></a></div><div
class="targettedEOFcol"><h2>Learn Responsive Web Design</h2><ul><li>SitePoint's ebook: <a
href="https://learnable.com/books/responsive1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Jump Start Responsive Web Design</a></li><li><a
href="https://learnable.com/courses/responsive-web-design-key-concepts-2759?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Responsive Web Design: Key Concepts</a> online course</li><li>Unlimited access to <a
href="https://learnable.com/topics/front-end?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign"> SitePoint Premium Content</a></li></ul><p><a
class="sptolbCTA" href="https://learnable.com/?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign#pricing">Join Learnable $29</a> <span><strong>Includes all SitePoint books</strong></span></div><div
class="targettedEOFbtn"></div></div><div
class="dfp-ad show-desktop"><div
id="div-gpt-ad-1340873946991-4" style="width: 728px; height: 90px;"> <script type="text/javascript">googletag.cmd.push(function() { googletag.display("div-gpt-ad-1340873946991-4"); });</script> </div></div></div></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=H2p0etyTivA:AYrCOyg7Gho:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=H2p0etyTivA:AYrCOyg7Gho:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=H2p0etyTivA:AYrCOyg7Gho:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?i=H2p0etyTivA:AYrCOyg7Gho:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SitepointFeed/~4/H2p0etyTivA" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/we-talked-javascript-with-the-experts-here-is-the-transcript/feed/</wfw:commentRss> <slash:comments>2</slash:comments> <feedburner:origLink>http://www.sitepoint.com/we-talked-javascript-with-the-experts-here-is-the-transcript/</feedburner:origLink></item> <item><title>Randomizing Sliding Puzzle Tiles</title><link>http://feedproxy.google.com/~r/SitepointFeed/~3/7taep2tgEmk/</link> <comments>http://www.sitepoint.com/randomizing-sliding-puzzle-tiles/#comments</comments> <pubDate>Wed, 15 May 2013 15:10:26 +0000</pubDate> <dc:creator>Bruce Alderman</dc:creator> <category><![CDATA[JavaScript]]></category> <guid isPermaLink="false">http://www.sitepoint.com/?p=66256</guid> <description><![CDATA[In a previous tutorial, Bruce Alderman demonstrated how to create a sliding puzzle game with HTML5 canvas. To randomize those tiles would require a separate tutorial to explain. This is that tutorial.]]></description> <content:encoded><![CDATA[<p></p><div><p>In a <a
href="http://www.sitepoint.com/image-manipulation-with-html5-canvas-a-sliding-puzzle-2/">previous tutorial</a>, I demonstrated how to create a sliding puzzle game with HTML5 canvas.</p><p>To save time I hard-coded the starting tile positions. Game play would be better if the tiles were randomized, but doing so would have led to complications that would require a separate tutorial to explain.</p><p>This is that tutorial.</p></div><p>There are a number of ways to randomize the tiles. I&#8217;ll look at a few options and discuss their strengths and weaknesses, as well as the problems that arise and how to overcome them.</p><p>One simple method is to initialize the puzzle in a solved state, then repeatedly call a function to slide a random piece into the empty space.</p><pre class="brush: jscript; title: ; notranslate">
  function initTiles() {
    var slideLoc = new Object;
    var direction = 0;
    for (var i = 0; i &lt; 30; ++i) {
      direction = Math.floor(Math.random()*4);
      slideLoc.x = emptyLoc.x;
      slideLoc.y = emptyLoc.y;
      if (direction == 0 &amp;&amp; slideLoc.x &gt; 0) {
        slideLoc.x = slideLoc.x - 1;
      } else if (direction == 1 &amp;&amp; slideLoc.y &gt; 0) {
        slideLoc.y = slideLoc.y - 1;
      } else if (direction == 2 &amp;&amp; slideLoc.x &lt; (tileCount - 1)) {
        slideLoc.x = slideLoc.x + 1;
      } else if (direction == 3 &amp;&amp; slideLoc.y &lt; (tileCount - 1)) {
        slideLoc.y = slideLoc.y + 1;
      }
      slideTile(emptyLoc, slideLoc);
    }
  }
</pre><p>In this case we&#8217;re sliding 30 tiles, twice the total number of tiles in the 4&#215;4 puzzle, and yet most of the pieces remain in their original locations. To get anything resembling randomness we would need many more iterations.<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><p>That&#8217;s not an efficient way to randomize the puzzle. Ideally, we&#8217;d like to move each piece only once. We could initialize the puzzle to a solved state, then iterate through the tiles, swapping each one with a tile chosen at random.</p><pre class="brush: jscript; title: ; notranslate">
  function initTiles() {
    for (var i = 0; i &lt; tileCount; ++i) {
      for (var j = 0; j &lt; tileCount; ++j) {
        var k = Math.floor(Math.random() * tileCount);
        var l = Math.floor(Math.random() * tileCount);
        swapTiles(i, j, k, l);
      }
    }
  }
  function swapTiles(i, j, k, l) {
    var temp = new Object();
    temp = boardParts[i][j];
    boardParts[i][j] = boardParts[k][l];
    boardParts[k][l] = temp;
  }
 </pre><p>Not only does this method give us a much more random-looking configuration, it does so in fewer lines of code. This algorithm, however, has two serious flaws. The first problem is subtle. Although swapping each tile with a random location is much more efficient than simply sliding pieces into the empty slot, this still is not a truly random algorithm. Some starting positions will show up much more frequently than others.</p><p>In a 2&#215;2 puzzle, some starting configurations will occur 87% more often than others. Add a third row and some configurations appear five times as often as others—and it continues to get worse as more tiles are added. Fortunately, there&#8217;s a way to achieve true randomness without adding extra complexity. It&#8217;s known as the Fisher-Yates algorithm.</p><pre class="brush: jscript; title: ; notranslate">
  function initTiles() {
    var i = tileCount * tileCount - 1;
    while (i &gt; 0) {
      var j = Math.floor(Math.random() * i);
      var xi = i % tileCount;
      var yi = Math.floor(i / tileCount);
      var xj = j % tileCount;
      var yj = Math.floor(j / tileCount);
      swapTiles(xi, yi, xj, yj);
      --i;
    }
  }
</pre><p>The mathematics of the Fisher-Yates are beyond the scope of this tutorial, but it does give every tile an equal chance to appear in any square. Using this algorithm, the puzzle is as random as the <code>Math.random()</code> function can get.</p><p>But swapping tiles randomly—with the Fisher-Yates algorithm or any other—leads to another problem. Half of all possible tile configurations give us a puzzle that can never be solved. To prevent unleashing an unsolvable puzzle on an innocent user, we need yet another algorithm.</p><p>Before I introduce this algorithm, I need to define two terms: inversion and polarity. An inversion is a pair of tiles that are in the reverse order from where they ought to be. The polarity of a puzzle is whether the total number of inversions among all tiles is even or odd. A puzzle with 10 inversions has even polarity; a puzzle with 7 inversions has odd polarity.</p><p>The solved puzzle has zero inversions (and even polarity) by definition. If we swapped two neighboring tiles from a solved puzzle, we would have one inversion.</p><p>In this game the board is configured as a two-dimensional array, each piece represented by its x/y coordinates.</p><p><img
class="alignnone size-full wp-image-66264" alt="figure1" src="http://www.sitepoint.com/wp-content/uploads/1/files/2013/05/figure14.png" width="138" height="124" /></p><p>But to work with inversions and polarity we’ll think of it as a one-dimensional array. We can convert each tile’s coordinates to a single number n with the formula n = y * w + x, where w is the width. Pictured as a single-dimension array the tiles are numbered like this.</p><p><img
class="alignnone size-full wp-image-66265" alt="figure2" src="http://www.sitepoint.com/wp-content/uploads/1/files/2013/05/figure22.png" width="136" height="124" /></p><p>Now let’s consider a randomized puzzle. It might look like this.</p><p><img
class="alignnone size-full wp-image-66266" alt="figure3" src="http://www.sitepoint.com/wp-content/uploads/1/files/2013/05/figure32.png" width="136" height="122" /></p><p>There are 19 inversions. Tile 6 is inverted with all six of the tiles numbered 0 through 5; 3 is inverted with 0, 1, and 2; 2 is inverted with 0 and 1; 4 is inverted with 0 and 1; 7 is inverted with 0, 1 and 5; 5 is inverted with 0 and 1; and 1 is inverted with 0.</p><p>To get this total, we need a function to count the inversions for each tile.</p><pre class="brush: jscript; title: ; notranslate">
  function countInversions(i, j) {
    var inversions = 0;
    var tileNum = j * tileCount + i;
    var lastTile = tileCount * tileCount;
    var tileValue = boardParts[i][j].y * tileCount + boardParts[i][j].x;
    for (var q = tileNum + 1; q &lt; lastTile; ++q) {
      var k = q % tileCount;
      var l = Math.floor(q / tileCount);
      var compValue = boardParts[k][l].y * tileCount + boardParts[k][l].x;
      if (tileValue &gt; compValue &amp;&amp; tileValue != (lastTile - 1)) {
        ++inversions;
      }
    }
    return inversions;
  }
</pre><p>Now we can iterate through the tiles and keep a running sum of the inversions.</p><pre class="brush: jscript; title: ; notranslate">
  function sumInversions() {
    var inversions = 0;
    for (var j = 0; j &lt; tileCount; ++j) {
      for (var i = 0; i &lt; tileCount; ++i) {
        inversions += countInversions(i, j);
      }
    }
    return inversions;
  }
</pre><p>Sliding a tile sideways does not change the number of inversions; the empty square has no number, so swapping it with an adjacent tile will always leave us with the same number of inversions. However, we might change the number of inversions when sliding a tile up or down. For example, if we slide the 6 tile down, we reduce the number of inversions from 19 to 17.</p><p><img
class="alignnone size-full wp-image-66267" alt="figure4" src="http://www.sitepoint.com/wp-content/uploads/1/files/2013/05/figure41.png" width="138" height="126" /></p><p>The rule is that sliding a tile up or down will change its relationship with w &#8211; 1 tiles, where w is the width of the puzzle. So for the 3&#215;3 puzzle, we are changing the tile’s relationship with two other tiles. This may result in a reduction of two inversions, an increase of two inversions, or no change. In the puzzle above, for example, sliding tile 5 up would have left us with 19 inversions, as it would gain an inversion with 4 and lose an inversion with 7.</p><p>A puzzle that starts with an even number of inversions will always have an even number of inversions; a puzzle with an odd number of inversions will always have an odd number of inversions. This is true not just for the 3&#215;3 puzzle, but for any puzzle with an odd width. If we’re ever going to reach zero inversions, we must start with an even number.</p><p>Since we&#8217;ve already calculated the number of inversions, a simple function will tell us whether the puzzle is solvable.</p><pre class="brush: jscript; title: ; notranslate">
  function isSolvable() {
    return (sumInversions() % 2 == 0)
  }
</pre><p>The example above is not solvable, since 19 is not even. But suppose the first two tiles were reversed?</p><p><img
class="alignnone size-full wp-image-66268" alt="figure5" src="http://www.sitepoint.com/wp-content/uploads/1/files/2013/05/figure51.png" width="137" height="124" /></p><p>Now we start with 18 inversions. The 3 and 6 are no longer inverted, but everything else remains the same. We have a solvable puzzle.</p><p>This gives us an elegant solution that preserves the puzzle’s true randomness—every unsolvable puzzle is paired with a unique solvable puzzle that differs only in the first two tiles.</p><pre class="brush: jscript; title: ; notranslate">
  if (!isSolvable()) {
    swapTiles(0, 0, 1, 0);
    initEmpty();
  }
</pre><p>Unfortunately, this won’t work if one of the swapped tiles is the empty square. We’ll need special code to deal with that situation.</p><pre class="brush: jscript; title: ; notranslate">
  if (!isSolvable()) {
    if (emptyLoc.y == 0 &amp;&amp; emptyLoc.x &lt;= 1) {
      swapTiles(tileCount - 2, tileCount - 1, tileCount - 1, tileCount - 1);
    } else {
      swapTiles(0, 0, 1, 0);
    }
    initEmpty();
  }
</pre><p>If the empty square is in one of the first two locations, we instead swap the last two tiles. This slightly skews the randomness, but we’re still much closer than any other algorithm can get us.</p><p>There’s just one problem remaining. If the width of the puzzle is an even number, sliding a tile up or down reverses the polarity. This is because, as we saw above, the tile changes its relationship with w &#8211; 1 tiles.</p><p><img
class="alignnone size-full wp-image-66269" alt="figure6" src="http://www.sitepoint.com/wp-content/uploads/1/files/2013/05/figure61.png" width="425" height="222" /></p><p>In order for the puzzle to be solvable, it must have an even polarity when the empty square is on the bottom row (assuming the empty square is on the bottom row when the puzzle is solved). When the empty square is on the next row up, the puzzle is solvable if the polarity is odd. So for an even-width puzzle, we must sum the inversions plus the distance between the empty row and the bottom row.</p><pre class="brush: jscript; title: ; notranslate">
  function isSolvable(width, height, emptyRow) {
    if (width % 2 == 1) {
      return (sumInversions() % 2 == 0)
    } else {
      return ((sumInversions() + height - emptyRow) % 2 == 0)
    }
  }
</pre><p>Now we must edit the line that calls this function.</p><pre class="brush: jscript; title: ; notranslate">
  if (!isSolvable(tileCount, tileCount, emptyLoc.y + 1))
</pre><p>There are a couple things to note here.</p><p>First, because the <code>emptyLoc</code> array is zero-based, we need to add one before comparing it with the height.</p><p>Second, for a square puzzle we don’t technically need two parameters for height and width; they are the same value, and we’re passing the <code>tileCount</code> variable to both. But separating them in the function clarifies which dimension is used in each equation. If we were to make a rectangular puzzle, we’d know where to use width and where to use height.</p><p>Randomizing a sliding puzzle turns out to be more work than creating the puzzle in the first place, but it’s worth the effort for the better game play it provides. You can see an example of a randomized puzzle <a
href="http://html5.brucealderman.info/sliderandom.html">here</a>.</p><div
class='after-content-widget-1'><div
id="sitepointcontextualcontentmanagerwidget-5" class="widget widget_sitepointcontextualcontentmanagerwidget"><style>#targettedEOF { width: 99%; font-family: "Open Sans", Helvetica, Arial, sans-serif; border-radius: 4px; border: 1px dotted #47B4DC; }
#targettedEOF .targettedEOFcol { float: left; padding: 20px; }
#targettedEOF .targettedEOFbtn { clear: both; padding: 0; }
#targettedEOF h2 { margin-top: 10px; }
#targettedEOF .sptolbCTA { border: 0 none; border-bottom: 2px solid #85bb41; background-color: #91c352; color: white; margin: 0; padding: 1em 1em; border-radius: 4px; vertical-align: middle; text-align: center; font-weight: 700; font-size: 17px; display: inline-block; line-height: 0; text-shadow: -1px -1px 1px rgba(0,0,0,0.2); cursor: pointer; text-decoration: none;
}
#targettedEOF .sptolbCTA:hover { color: white; }
#targettedEOF .targettedEOFbtn p { padding: 0; margin: 0; }
.cat_javascript #targettedEOF h2, .cat_cloudspring #targettedEOF h2 { font-size: 1.267em; line-height: 1.158em; margin: 1.737em 0 0.579em 0; font-weight: bold; color: #0071D8; }
.cat_javascript #targettedEOF, .cat_cloudspring #targettedEOF { font-size: 1.5em; line-height: 1.467em; width: 100%; }
.cat_javascript #targettedEOF ul, .cat_cloudspring #targettedEOF ul { list-style: square; margin: 0 0 1.467em 1.467em; }</style><div
id="targettedEOF"><div
class="targettedEOFcol"> <a
href="https://learnable.com/books/jsjavascript1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=UltimateJavaScriptBundle"><img
src="https://learnable-images.s3.amazonaws.com/books/responsive1_medium.jpg" width="145"></a></div><div
class="targettedEOFcol"><h2>Learn Responsive Web Design</h2><ul><li>SitePoint's ebook: <a
href="https://learnable.com/books/responsive1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Jump Start Responsive Web Design</a></li><li><a
href="https://learnable.com/courses/responsive-web-design-key-concepts-2759?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Responsive Web Design: Key Concepts</a> online course</li><li>Unlimited access to <a
href="https://learnable.com/topics/front-end?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign"> SitePoint Premium Content</a></li></ul><p><a
class="sptolbCTA" href="https://learnable.com/?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign#pricing">Join Learnable $29</a> <span><strong>Includes all SitePoint books</strong></span></div><div
class="targettedEOFbtn"></div></div><div
class="dfp-ad show-desktop"><div
id="div-gpt-ad-1340873946991-4" style="width: 728px; height: 90px;"> <script type="text/javascript">googletag.cmd.push(function() { googletag.display("div-gpt-ad-1340873946991-4"); });</script> </div></div></div></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=7taep2tgEmk:jOftXWp03Sk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=7taep2tgEmk:jOftXWp03Sk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=7taep2tgEmk:jOftXWp03Sk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?i=7taep2tgEmk:jOftXWp03Sk:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SitepointFeed/~4/7taep2tgEmk" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/randomizing-sliding-puzzle-tiles/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://www.sitepoint.com/randomizing-sliding-puzzle-tiles/</feedburner:origLink></item> <item><title>Take Your JavaScript to the Next Level with the Experts</title><link>http://feedproxy.google.com/~r/SitepointFeed/~3/sY-P6_yEDS8/</link> <comments>http://www.sitepoint.com/take-your-javascript-to-the-next-level-with-the-experts/#comments</comments> <pubDate>Wed, 15 May 2013 14:29:21 +0000</pubDate> <dc:creator>Ricky Onsman</dc:creator> <category><![CDATA[JavaScript]]></category> <guid isPermaLink="false">http://www.sitepoint.com/?p=66235</guid> <description><![CDATA[Talk with our JavaScript experts and be inspired to master a key language for front and back end web development. We have the resources for you.]]></description> <content:encoded><![CDATA[<p></p><p>When Craig Buckler researched the <a
href="http://www.sitepoint.com/best-programming-language-of-2013/" target="_blank">best programming language to learn in 2013</a>, he found that demand for JavaScript has increased faster than for any other language.</p><p>As the web evolves, JavaScript keeps raising its status as a proper programming language to be taken seriously and learned fully, rather than being just that code snippet you use without really knowing how it works, or even just that language that sits somewhere behind jQuery and other libraries.</p><p>At SitePoint, we’ve been watching this trend, listening to our readers’ feedback and plotting a flexible learning path to enhancing your JavaScript skills. Now is a perfect time for you to get comfortable with what is likely to be a key partner for HTML and CSS for some time to come.</p><h2><a
href="https://experts.learnable.com" target="_blank">Talk with the Experts</a></h2><p>Today, Wednesday May 15, at 2:30pm PDT, you have our JS experts Ara Pehlivanian and Don Nguyen all to yourselves for free, to ask them any questions about JavaScript you may have. Best practices, trends, libraries, big or small challenges, anything. They will be there waiting for you. Transcripts will be available after the event. <a
href="https://experts.learnable.com" target="_blank">More here</a>.</p><h2><a
href="https://learnable.com/books/jsjavascript1" target="_blank">Jump Start JavaScript eBook</a></h2><p>As our JavaScript experts, Ara and Don compiled a 150 page guide to mastering the fundamentals of JavaScript. The book steps you through an app project that provides the perfect base for anyone getting started with JavaScript or needing the context to explain what they&#8217;ve been using so far. The focus is on pragmatism and practical contexts. <a
href="https://learnable.com/books/jsjavascript1" target="_blank">More here</a>.</p><h2>The JavaScript resource List</h2><p>Between SitePoint and Learnable, we have amassed an impressive collection of instructional resources related to JavaScript: books, video courses, tutorial articles and screencasts by some of the most skilled exponents of JavaScript around. We&#8217;ve taken in which of those have been getting the most of your attention and positive feedback, and we&#8217;ve given thought to what content delivers the greatest benefit to web professionals, now and into the future.</p><p>The upshot is that we&#8217;re just about ready to publish a shortlist of our best JavaScript content available on SitePoint and Learnable: enough material to get anyone pumped to write the best JavaScript code ever.</p><p>So, if you&#8217;re keen to embrace JavaScript and bring it securely within your skillset, join in the Talk with the Experts session tomorrow (lurking is perfectly acceptable) and take a look at Jump Start JavaScript.</p><p>Tomorrow, we&#8217;ll publish our resource list, and you&#8217;ll be ready to take your JavaScript skills to a new level, whether that&#8217;s as a beginner or a practised scripter looking for more advanced techniques.</p><div
class='after-content-widget-1'><div
id="sitepointcontextualcontentmanagerwidget-5" class="widget widget_sitepointcontextualcontentmanagerwidget"><style>#targettedEOF { width: 99%; font-family: "Open Sans", Helvetica, Arial, sans-serif; border-radius: 4px; border: 1px dotted #47B4DC; }
#targettedEOF .targettedEOFcol { float: left; padding: 20px; }
#targettedEOF .targettedEOFbtn { clear: both; padding: 0; }
#targettedEOF h2 { margin-top: 10px; }
#targettedEOF .sptolbCTA { border: 0 none; border-bottom: 2px solid #85bb41; background-color: #91c352; color: white; margin: 0; padding: 1em 1em; border-radius: 4px; vertical-align: middle; text-align: center; font-weight: 700; font-size: 17px; display: inline-block; line-height: 0; text-shadow: -1px -1px 1px rgba(0,0,0,0.2); cursor: pointer; text-decoration: none;
}
#targettedEOF .sptolbCTA:hover { color: white; }
#targettedEOF .targettedEOFbtn p { padding: 0; margin: 0; }
.cat_javascript #targettedEOF h2, .cat_cloudspring #targettedEOF h2 { font-size: 1.267em; line-height: 1.158em; margin: 1.737em 0 0.579em 0; font-weight: bold; color: #0071D8; }
.cat_javascript #targettedEOF, .cat_cloudspring #targettedEOF { font-size: 1.5em; line-height: 1.467em; width: 100%; }
.cat_javascript #targettedEOF ul, .cat_cloudspring #targettedEOF ul { list-style: square; margin: 0 0 1.467em 1.467em; }</style><div
id="targettedEOF"><div
class="targettedEOFcol"> <a
href="https://learnable.com/books/jsjavascript1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=UltimateJavaScriptBundle"><img
src="https://learnable-images.s3.amazonaws.com/books/responsive1_medium.jpg" width="145"></a></div><div
class="targettedEOFcol"><h2>Learn Responsive Web Design</h2><ul><li>SitePoint's ebook: <a
href="https://learnable.com/books/responsive1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Jump Start Responsive Web Design</a></li><li><a
href="https://learnable.com/courses/responsive-web-design-key-concepts-2759?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Responsive Web Design: Key Concepts</a> online course</li><li>Unlimited access to <a
href="https://learnable.com/topics/front-end?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign"> SitePoint Premium Content</a></li></ul><p><a
class="sptolbCTA" href="https://learnable.com/?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign#pricing">Join Learnable $29</a> <span><strong>Includes all SitePoint books</strong></span></div><div
class="targettedEOFbtn"></div></div><div
class="dfp-ad show-desktop"><div
id="div-gpt-ad-1340873946991-4" style="width: 728px; height: 90px;"> <script type="text/javascript">googletag.cmd.push(function() { googletag.display("div-gpt-ad-1340873946991-4"); });</script> </div></div></div></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=sY-P6_yEDS8:0IGV-PaRosU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=sY-P6_yEDS8:0IGV-PaRosU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=sY-P6_yEDS8:0IGV-PaRosU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?i=sY-P6_yEDS8:0IGV-PaRosU:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SitepointFeed/~4/sY-P6_yEDS8" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/take-your-javascript-to-the-next-level-with-the-experts/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <feedburner:origLink>http://www.sitepoint.com/take-your-javascript-to-the-next-level-with-the-experts/</feedburner:origLink></item> <item><title>What’s New in Firefox 21</title><link>http://feedproxy.google.com/~r/SitepointFeed/~3/jDfBp9ELBV4/</link> <comments>http://www.sitepoint.com/firefox-21-whats-new/#comments</comments> <pubDate>Wed, 15 May 2013 10:03:18 +0000</pubDate> <dc:creator>Craig Buckler</dc:creator> <category><![CDATA[Browsers]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[CSS3]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[HTML5]]></category> <category><![CDATA[News]]></category> <category><![CDATA[Open source]]></category> <category><![CDATA[firefox]]></category> <category><![CDATA[HTML5 Dev Center]]></category> <category><![CDATA[HTML5 Tutorials & Articles]]></category> <category><![CDATA[Mozilla]]></category> <guid isPermaLink="false">http://www.sitepoint.com/?p=66247</guid> <description><![CDATA[Firefox has come of age. Craig looks at the latest useful -- and not so useful -- features in Mozilla's flagship browser.]]></description> <content:encoded><![CDATA[<p></p><p>Firefox has come of age. In version numbers, that is.</p><p>Firefox 21 was released on May 14, 2013. If you&#8217;ve not received the update, click Help &gt; About Firefox &gt; Check for Updates. Let&#8217;s look at the new features you can expect after installation&hellip;</p><h2>&lt;main&gt; Element Support</h2><p>The <a
href="/html5-main-element/">HTML5 &lt;main&gt; element</a> was introduced earlier this year and represents the main content of the body of a document or application, i.e. perhaps a wrapper for an article and aside.</p><p>It&#8217;s simply a container tag and all browsers will render it regardless. Firefox &#8220;support&#8221; probably means it defaults to a block element rather than inline, but you&#8217;ll still require <code>display:block;</code> for other browsers.</p><h2>Scoped Stylesheets</h2><p>If you&#8217;ve ever included third-party content on your page, you may find it contains CSS code which pollutes your own styles. Scoped stylesheets restricts style rules to the enclosing container without the necessity to use an iframe, e.g.</p><pre><code>&lt;article&gt;
	&lt;p&gt;This paragraph is the standard page color.&lt;/p&gt;
&lt;/article&gt;
&lt;aside&gt;
	&lt;style scoped&gt;
		p { color: red; }
	&lt;/style&gt;
	&lt;p&gt;Only paragraphs within this aside element are red.&lt;/p&gt;
&lt;/aside&gt;
</code></pre><p>Very useful. Unfortunately, only Firefox supports scoped CSS but IE11 and Chrome (and therefore Opera) should receive the technology soon.<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><h2>Health Report</h2><p>A preliminary implementation of the Health Report has been added to version 21. Non-personal Firefox data will be logged in the browser and to a central location including:</p><ul><li>configuration details, e.g. hardware, OS, browser version, etc.</li><li>customization details, e.g. add-ons, plugins, options, etc.</li><li>performance data, e.g. timing of browser events, rendering, etc.</li><li>wear and tear data, e.g. session age, profile age, crashes, etc</li></ul><p>Information is collated in the Health Report which allows you and Mozilla to determine performance issues. To view it, click Help &gt; Firefox Health Report from the menu or enter <a
href="healthreport" class="broken_link">about:healthreport</a> in the address bar <em>(wohh &#8212; I have 3,519 bookmarks &hellip; that explains a lot!)</em></p><p>Mozilla are monitoring your browser software rather than your activities or visited sites but, if you have privacy concerns, it can be disabled in the Health Report itself or in Options &gt; Advanced &gt; Data Choices tab &gt; Enable Firefox Health Report.</p><h2>Three-State Do Not Track</h2><p><a
href="/what-is-do-not-track/">&#8220;Do Not Track&#8221; (DNT)</a> is a W3C Recommendation implemented in most browsers. A DNT field is sent with every HTTP header which, if set to 1, means the site should prevent the user&#8217;s actions being tracked across two or more domains.</p><p>Firefox 21 introduces a new <em>&#8220;Do not tell&#8221;</em> option:</p><p><img
src="http://blog.mozilla.org/privacy/files/2013/01/Screen-Shot-2013-01-25-at-4.13.37-PM.png" width="605" alt="Do Not Track" class="center" /></p><p>The option removes the DNT header so a site is not aware of your preference. It&#8217;s a minor privacy improvement, but I suspect DNT isn&#8217;t being widely implemented at this time.</p><h2>Social API</h2><p>My heart sank when I saw this feature. Social media integration has never been successful; ask anyone who used the Flock or Rockmelt browsers. If I want to catch up with friends and colleagues, I can visit a social networking site or use an app &#8212; I don&#8217;t need Firefox to drip-feed a steady stream of inane drivel!</p><p>The Social API provides a sidebar which shows messages from Facebook. Or Cliqz, Mixi and msnNOW <em>&#8211; yep &#8212; I&#8217;d not heard of them either?</em></p><p><img
src="http://blog.mozilla.org/files/2013/05/MSN-Screen-shot.png" width="600" alt="Social API" class="center" /></p><p>According to Mozilla:</p><blockquote><p>The Social API has endless potential for integrating social networks, e-mail, finance, music, cloud possibilities, services, to-do lists, sports, news and other applications into your Firefox experience.</p></blockquote><p>I&#8217;m less convinced. Will it be different to loading a site in the sidebar? Will publishers use the feature if it&#8217;s only supported by one browser? Perhaps I&#8217;ll be proved wrong but, unless this becomes an HTML5 Recommendation, I&#8217;m cynical about its future.</p><h2>Android Updates</h2><p>Firefox 21 on Android has received various HTML5 updates and now scores 421 out of 500 on <a
href="http://html5test.com">html5test.com</a>.</p><p>As well as the Gecko changes detailed above, the new mobile browser also provides:</p><ul><li>integrated support for the Charis and Open Sans fonts which Mozilla claim is &#8220;a more visually appealing and clear reading experience on the Web&#8221;</li><li>the ability to save media files with a long tap</li><li>access to the recent history via the back and forward buttons</li><li>a newly-polished interface.</li></ul><p>Admittedly, Firefox 21 is less exciting than previous releases but Mozilla continues to evolve the browser at a pace that makes Google look sluggish. See you again in six weeks for Firefox 22.</p><div
class='after-content-widget-1'><div
id="sitepointcontextualcontentmanagerwidget-5" class="widget widget_sitepointcontextualcontentmanagerwidget"><style>#targettedEOF { width: 99%; font-family: "Open Sans", Helvetica, Arial, sans-serif; border-radius: 4px; border: 1px dotted #47B4DC; }
#targettedEOF .targettedEOFcol { float: left; padding: 20px; }
#targettedEOF .targettedEOFbtn { clear: both; padding: 0; }
#targettedEOF h2 { margin-top: 10px; }
#targettedEOF .sptolbCTA { border: 0 none; border-bottom: 2px solid #85bb41; background-color: #91c352; color: white; margin: 0; padding: 1em 1em; border-radius: 4px; vertical-align: middle; text-align: center; font-weight: 700; font-size: 17px; display: inline-block; line-height: 0; text-shadow: -1px -1px 1px rgba(0,0,0,0.2); cursor: pointer; text-decoration: none;
}
#targettedEOF .sptolbCTA:hover { color: white; }
#targettedEOF .targettedEOFbtn p { padding: 0; margin: 0; }
.cat_javascript #targettedEOF h2, .cat_cloudspring #targettedEOF h2 { font-size: 1.267em; line-height: 1.158em; margin: 1.737em 0 0.579em 0; font-weight: bold; color: #0071D8; }
.cat_javascript #targettedEOF, .cat_cloudspring #targettedEOF { font-size: 1.5em; line-height: 1.467em; width: 100%; }
.cat_javascript #targettedEOF ul, .cat_cloudspring #targettedEOF ul { list-style: square; margin: 0 0 1.467em 1.467em; }</style><div
id="targettedEOF"><div
class="targettedEOFcol"> <a
href="https://learnable.com/books/jsjavascript1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=UltimateJavaScriptBundle"><img
src="https://learnable-images.s3.amazonaws.com/books/responsive1_medium.jpg" width="145"></a></div><div
class="targettedEOFcol"><h2>Learn Responsive Web Design</h2><ul><li>SitePoint's ebook: <a
href="https://learnable.com/books/responsive1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Jump Start Responsive Web Design</a></li><li><a
href="https://learnable.com/courses/responsive-web-design-key-concepts-2759?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Responsive Web Design: Key Concepts</a> online course</li><li>Unlimited access to <a
href="https://learnable.com/topics/front-end?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign"> SitePoint Premium Content</a></li></ul><p><a
class="sptolbCTA" href="https://learnable.com/?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign#pricing">Join Learnable $29</a> <span><strong>Includes all SitePoint books</strong></span></div><div
class="targettedEOFbtn"></div></div><div
class="dfp-ad show-desktop"><div
id="div-gpt-ad-1340873946991-4" style="width: 728px; height: 90px;"> <script type="text/javascript">googletag.cmd.push(function() { googletag.display("div-gpt-ad-1340873946991-4"); });</script> </div></div></div></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=jDfBp9ELBV4:zswnL3iN_r8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=jDfBp9ELBV4:zswnL3iN_r8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=jDfBp9ELBV4:zswnL3iN_r8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?i=jDfBp9ELBV4:zswnL3iN_r8:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SitepointFeed/~4/jDfBp9ELBV4" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/firefox-21-whats-new/feed/</wfw:commentRss> <slash:comments>5</slash:comments> <feedburner:origLink>http://www.sitepoint.com/firefox-21-whats-new/</feedburner:origLink></item> <item><title>Mobile Website Security</title><link>http://feedproxy.google.com/~r/SitepointFeed/~3/EVFPYec9yk0/</link> <comments>http://www.sitepoint.com/mobile-website-security/#comments</comments> <pubDate>Tue, 14 May 2013 15:30:00 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[BuildMobile]]></category> <category><![CDATA[Mobile]]></category> <category><![CDATA[Web security]]></category> <guid isPermaLink="false">http://www.sitepoint.com/?p=66207</guid> <description><![CDATA[As mobile ecommerce grows, David Walsh suggests it's time to improve security to compensate for the more open nature of mobile data connections and public Wi-Fi networks.]]></description> <content:encoded><![CDATA[<p></p><h2>Are you Creating a Secured Mobile Site?</h2><p>In an era when consumers are increasingly shifting all of their social media, shopping, and buying habits to their smartphones and tablet devices, many companies have deployed mobile versions of their websites in order to encourage strong sales across platforms.</p><p>This is good business sense, but it comes with a number of security-related considerations. After all, mobile devices are being used in the public space during the vast majority of purchases, and they&#8217;re bound to be transmitting data over open Wi-Fi networks, mobile data networks, and other connections that usually aren&#8217;t as private and secure as a home broadband connection.</p><p>Designers and developers have already mastered creating a robust, touch-friendly website for today&#8217;s smartphones and tablets. As ecommerce implementations rise, though, it&#8217;s time to start considering how to create a highly secure mobile site that will protect shoppers&#8217; identities, defend against hackers and identity thieves, and compensate for the more open nature of mobile data connections and public Wi-Fi networks that these devices use most often. Protecting consumer data comes down to a few major tips and considerations.</p><h3>1. Choose a Highly Secure Web Host</h3><p>Web hosts have security reputations, just as websites, Wi-Fi connections, and shopping cart options do. Many hosts offer Secure Socket Layer connections, often called SSL encryption, for a small additional fee to those customers that require a highly secure connection between any consumer device and their own shopping cart software. Only those web hosts that offer such a connection should be chosen to serve mobile sites to consumers that are likely using a public network. Furthermore, SSL should be implemented for both desktop and mobile users.<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><p>It might be a good idea to contact an existing web host specifically to inquire about their security procedures both on the backend and in implementations that face a website&#8217;s users. By making sure that hackers can&#8217;t compromise the host, and can&#8217;t compromise the company&#8217;s website, greater protection against data loss and identity thief can contribute to a better mobile business.</p><h3>2. Don&#8217;t Be Afraid to Implement Secure Socket Layers for Mobile Devices</h3><p>SSL has long been a mainstay of desktop ecommerce websites, since the technology essentially creates a highly encrypted, very secure connection between one consumer and the website&#8217;s server. This technology&#8217;s popularity on desktops is due in no small part to its effectiveness, serving as one of the best ways to deter hackers. Mobile commerce sites, though, tend to implement SSL inconsistently.</p><p>This lack of SSL implementation for mobile buyers might be because mobile browsers were once limited in their use of SSL and &#8220;https&#8221; websites. That has all changed, though, and today&#8217;s mobile browsers are just as sophisticated as the ones used on desktops. They&#8217;re adept at handling SSL encryption and managing encrypted transactions, and developers should take advantage of this functionality right away.</p><h3>3. Comply with Mobile PCI Security Standards</h3><p>The Payment Card Industry CI Security Council, often abbreviated as the PCI Security Council, is the regulatory body that governs all transactions involves credit and debit carts online and off. The organization has long had a list of requirements and recommendations for developing desktop sites, but it wasn&#8217;t until recently that they got heavily involved in mobile transactions. It&#8217;s not a moment too soon, of course, with so many sites now engaging in mobile commerce.</p><p>The PCI Security Council has released a list of recommendations and guidelines for mobile websites that encourage mobile commerce and accept plastic as a form of payment. The document can be found on the organization&#8217;s website, and its implementation is the best way to gain PCI certification and consumer confidence at the same time.</p><h3>4. Choose a Payment Gateway Developed for Mobile Implementation</h3><p>Numerous companies have created mobile-specific payment solutions that implement the full list of PCI security standards while keeping customers engaged and encouraging them to complete a sale using their mobile device. These payment solutions involve both third-party websites and transitional web software solutions that can be deployed by the website&#8217;s owner for use locally.</p><p>In addition to PCI compliance, these systems offer another benefit that will help with deployment: because they&#8217;re designed specifically for mobile transactions, they often come with touch-friendly designs, mobile-friendly language, and an intuitive administration interface that scales well to both desktops and portable devices.</p><h3>5. Create a Mobile Security Policy</h3><p>Online retailers have worked hard to <a
href="http://www.sitepoint.com/why-mobile-apps-need-privacy-policies-and-how-to-get-yours-right/">create robust privacy policies</a>, but it&#8217;s now time to focus on a new type of policy. With mobile security policies, websites can clearly state which pieces of information they require from consumers, why they require it, and how it is used. Furthermore, this policy actually helps the website guide its mobile ecommerce development, since they will know exactly which user input fields to place in their mobile payment setup.</p><p>Remember that a mobile security policy should be the right balance of &#8220;short and sweet&#8221; with enough detail to guide future website developments and provide peace of mind to consumers who may be purchasing via mobile for the first time.</p><h2>Clearly Defined Objectives and Industry Compliance are the Keys to Success</h2><p>With a clear policy of mobile security and adherence to industry standards that govern transaction security and encryption, retailers that encourage mobile purchases will be able to safeguard themselves from malicious hackers, as well as from potential legal hurdles that might arise without a strong security policy and robust encryption. With the right policies and tools in place, consumers will feel more at ease with mobile commerce, and they&#8217;ll be more likely to buy what the company has to offer no matter where they are, or whose data connection they&#8217;re using.</p><div
class='after-content-widget-1'><div
id="sitepointcontextualcontentmanagerwidget-5" class="widget widget_sitepointcontextualcontentmanagerwidget"><style>#targettedEOF { width: 99%; font-family: "Open Sans", Helvetica, Arial, sans-serif; border-radius: 4px; border: 1px dotted #47B4DC; }
#targettedEOF .targettedEOFcol { float: left; padding: 20px; }
#targettedEOF .targettedEOFbtn { clear: both; padding: 0; }
#targettedEOF h2 { margin-top: 10px; }
#targettedEOF .sptolbCTA { border: 0 none; border-bottom: 2px solid #85bb41; background-color: #91c352; color: white; margin: 0; padding: 1em 1em; border-radius: 4px; vertical-align: middle; text-align: center; font-weight: 700; font-size: 17px; display: inline-block; line-height: 0; text-shadow: -1px -1px 1px rgba(0,0,0,0.2); cursor: pointer; text-decoration: none;
}
#targettedEOF .sptolbCTA:hover { color: white; }
#targettedEOF .targettedEOFbtn p { padding: 0; margin: 0; }
.cat_javascript #targettedEOF h2, .cat_cloudspring #targettedEOF h2 { font-size: 1.267em; line-height: 1.158em; margin: 1.737em 0 0.579em 0; font-weight: bold; color: #0071D8; }
.cat_javascript #targettedEOF, .cat_cloudspring #targettedEOF { font-size: 1.5em; line-height: 1.467em; width: 100%; }
.cat_javascript #targettedEOF ul, .cat_cloudspring #targettedEOF ul { list-style: square; margin: 0 0 1.467em 1.467em; }</style><div
id="targettedEOF"><div
class="targettedEOFcol"> <a
href="https://learnable.com/books/jsjavascript1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=UltimateJavaScriptBundle"><img
src="https://learnable-images.s3.amazonaws.com/books/responsive1_medium.jpg" width="145"></a></div><div
class="targettedEOFcol"><h2>Learn Responsive Web Design</h2><ul><li>SitePoint's ebook: <a
href="https://learnable.com/books/responsive1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Jump Start Responsive Web Design</a></li><li><a
href="https://learnable.com/courses/responsive-web-design-key-concepts-2759?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Responsive Web Design: Key Concepts</a> online course</li><li>Unlimited access to <a
href="https://learnable.com/topics/front-end?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign"> SitePoint Premium Content</a></li></ul><p><a
class="sptolbCTA" href="https://learnable.com/?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign#pricing">Join Learnable $29</a> <span><strong>Includes all SitePoint books</strong></span></div><div
class="targettedEOFbtn"></div></div><div
class="dfp-ad show-desktop"><div
id="div-gpt-ad-1340873946991-4" style="width: 728px; height: 90px;"> <script type="text/javascript">googletag.cmd.push(function() { googletag.display("div-gpt-ad-1340873946991-4"); });</script> </div></div></div></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=EVFPYec9yk0:U9-ka9ybZOg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=EVFPYec9yk0:U9-ka9ybZOg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=EVFPYec9yk0:U9-ka9ybZOg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?i=EVFPYec9yk0:U9-ka9ybZOg:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SitepointFeed/~4/EVFPYec9yk0" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/mobile-website-security/feed/</wfw:commentRss> <slash:comments>1</slash:comments> <feedburner:origLink>http://www.sitepoint.com/mobile-website-security/</feedburner:origLink></item> <item><title>What to Do with Prospects Who “Just Don’t Get It”</title><link>http://feedproxy.google.com/~r/SitepointFeed/~3/C8TWwb15H5E/</link> <comments>http://www.sitepoint.com/what-to-do-with-prospects-who-just-dont-get-it/#comments</comments> <pubDate>Tue, 14 May 2013 13:30:14 +0000</pubDate> <dc:creator>John Tabita</dc:creator> <category><![CDATA[Business]]></category> <category><![CDATA[Freelancing]]></category> <category><![CDATA[General business]]></category> <category><![CDATA[Marketing]]></category> <category><![CDATA[clients]]></category> <category><![CDATA[freelance]]></category> <category><![CDATA[freelancing]]></category> <category><![CDATA[sales]]></category> <category><![CDATA[selling]]></category> <category><![CDATA[selling your services]]></category> <category><![CDATA[small business]]></category> <guid isPermaLink="false">http://www.sitepoint.com/?p=66174</guid> <description><![CDATA[Frustrated over clients who just don't seem to get it? You may be missing a key ingredient in your sales presentation.]]></description> <content:encoded><![CDATA[<p></p><p>It makes perfect sense to you and me. If that restaurant or hair salon doesn’t have a mobile website, they’re losing customers and therefore money. Yet, surprisingly, that restaurant or salon owner can’t seem to make the connection.</p><p>When selling any type of advertising or market—be it a print ad, website, or search engine optimization—there’s an inevitable disconnect that occurs. Your prospect is unable to connect the dots and understand how what you’re selling puts more money in his pocket.</p><p>That’s because your prospect is not the end-user of what you’re selling. His customer is the one who’s going to interact with his website or advertising. So all the supposed “features and benefits” don’t benefit your prospect in the least. Hence, the disconnect.</p><p>Take a Yellow Page ad, for example. The phone directory in which that ad is placed is designed to appeal to the end-user, your customer’s customer—it’s full of information and easy-to-use. The same can be said of a website. Your customer benefits indirectly, when that consumer finds his website or print ad, and calls.</p><p>That’s why “features and benefits” don’t work when selling advertising and marketing. What needs to replace “features and benefits” is “usage and action.” How does your customer’s customer <em>use the advertising platform</em> and <em>what action do they take</em> as a result?<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><p>So going back to my Yellow Pages example, I can say the following:</p><ul><li><strong>Usage:</strong> 69 percent of San Francisco Bay Area residents <a
title="Survey: 69% Use Print YP in SF Bay Area" href="http://screenwerk.com/2012/02/14/survey-69-still-using-print-yp-in-sf-bay-area/" target="_blank">use the Yellow Pages</a>.</li><li><strong>Action:</strong> 82 percent of Yellow Pages users contact a merchant, and 46 percent make a purchase.</li></ul><p>In order to cross the chasm between product and profit, Yellow Page sales people have used a technique called “picturing the buyer.” That’s when you get your prospect to step out of advertiser mode and into consumer mode, by getting him to flip through the directory, view the ads inside, and imagine how his customer would look for and find him there.</p><p>Now, phone directories have been around for over 120 years, so there’s a good chance your prospect has used the Yellow Pages in his lifetime. But with digital marketing, not so much. Getting your prospect to grasp and understand how a consumer would search for a local business on a smartphone—when he’s never used one—is a challenge, to say the least. But unless you bridge that gap, you won’t succeed at selling your web marketing services.</p><p>In the same manner you’d get a potential Yellow Page advertiser “into the book,” you’ll need to demonstrate how a mobile consumer would conduct a local search for his business category on a smartphone (there’s also the added benefit of your prospect realizing his competitors’ listings appear above his).</p><p>Picturing the buyer is an effective method for getting your prospect to step into his customers&#8217; shoes and understand how the average consumer uses technology to search for the products and services they need. Use it to help your prospect to “connect the dots” between what you’re selling and what puts money in his pocket—or else be forever frustrated with clients who “just don’t get it.”</p><p
style="text-align: right"><a
href="http://www.sxc.hu/profile/brainloc" target="_blank"><em>Image credit</em></a></p><div
class='after-content-widget-1'><div
id="sitepointcontextualcontentmanagerwidget-5" class="widget widget_sitepointcontextualcontentmanagerwidget"><style>#targettedEOF { width: 99%; font-family: "Open Sans", Helvetica, Arial, sans-serif; border-radius: 4px; border: 1px dotted #47B4DC; }
#targettedEOF .targettedEOFcol { float: left; padding: 20px; }
#targettedEOF .targettedEOFbtn { clear: both; padding: 0; }
#targettedEOF h2 { margin-top: 10px; }
#targettedEOF .sptolbCTA { border: 0 none; border-bottom: 2px solid #85bb41; background-color: #91c352; color: white; margin: 0; padding: 1em 1em; border-radius: 4px; vertical-align: middle; text-align: center; font-weight: 700; font-size: 17px; display: inline-block; line-height: 0; text-shadow: -1px -1px 1px rgba(0,0,0,0.2); cursor: pointer; text-decoration: none;
}
#targettedEOF .sptolbCTA:hover { color: white; }
#targettedEOF .targettedEOFbtn p { padding: 0; margin: 0; }
.cat_javascript #targettedEOF h2, .cat_cloudspring #targettedEOF h2 { font-size: 1.267em; line-height: 1.158em; margin: 1.737em 0 0.579em 0; font-weight: bold; color: #0071D8; }
.cat_javascript #targettedEOF, .cat_cloudspring #targettedEOF { font-size: 1.5em; line-height: 1.467em; width: 100%; }
.cat_javascript #targettedEOF ul, .cat_cloudspring #targettedEOF ul { list-style: square; margin: 0 0 1.467em 1.467em; }</style><div
id="targettedEOF"><div
class="targettedEOFcol"> <a
href="https://learnable.com/books/jsjavascript1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=UltimateJavaScriptBundle"><img
src="https://learnable-images.s3.amazonaws.com/books/responsive1_medium.jpg" width="145"></a></div><div
class="targettedEOFcol"><h2>Learn Responsive Web Design</h2><ul><li>SitePoint's ebook: <a
href="https://learnable.com/books/responsive1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Jump Start Responsive Web Design</a></li><li><a
href="https://learnable.com/courses/responsive-web-design-key-concepts-2759?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Responsive Web Design: Key Concepts</a> online course</li><li>Unlimited access to <a
href="https://learnable.com/topics/front-end?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign"> SitePoint Premium Content</a></li></ul><p><a
class="sptolbCTA" href="https://learnable.com/?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign#pricing">Join Learnable $29</a> <span><strong>Includes all SitePoint books</strong></span></div><div
class="targettedEOFbtn"></div></div><div
class="dfp-ad show-desktop"><div
id="div-gpt-ad-1340873946991-4" style="width: 728px; height: 90px;"> <script type="text/javascript">googletag.cmd.push(function() { googletag.display("div-gpt-ad-1340873946991-4"); });</script> </div></div></div></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=C8TWwb15H5E:xt01Dzqt9vw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=C8TWwb15H5E:xt01Dzqt9vw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=C8TWwb15H5E:xt01Dzqt9vw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?i=C8TWwb15H5E:xt01Dzqt9vw:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SitepointFeed/~4/C8TWwb15H5E" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/what-to-do-with-prospects-who-just-dont-get-it/feed/</wfw:commentRss> <slash:comments>2</slash:comments> <feedburner:origLink>http://www.sitepoint.com/what-to-do-with-prospects-who-just-dont-get-it/</feedburner:origLink></item> <item><title>CSS3 Pong: Insane Things to Do with CSS #17</title><link>http://feedproxy.google.com/~r/SitepointFeed/~3/LOy2lsgO0OM/</link> <comments>http://www.sitepoint.com/css3-pong-insane-things-to-do-with-css/#comments</comments> <pubDate>Tue, 14 May 2013 13:01:09 +0000</pubDate> <dc:creator>Alex Walker</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[CSS3]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[css animation]]></category> <category><![CDATA[games]]></category> <category><![CDATA[hacks]]></category> <category><![CDATA[hover]]></category> <category><![CDATA[interactivity]]></category> <category><![CDATA[pong]]></category> <category><![CDATA[sibling selectors]]></category> <guid isPermaLink="false">http://www.sitepoint.com/?p=66114</guid> <description><![CDATA[Alex Walker. CSS3. Pong. How close can one man - armed only with modern code - come to replicating an iconic game?]]></description> <content:encoded><![CDATA[<p></p><div
id="attachment_8514" class="wp-caption alignright" style="width: 334px"> <a
href="http://designfestival.com/files/2012/05/minecraft.jpg"><img
class="size-full wp-image-8514" src="http://designfestival.com/files/2012/05/minecraft.jpg" alt="" width="334" height="218" /></a><p
class="wp-caption-text">Pop Quiz: What is this?</p></div><p>Before we kick things off, let&#8217;s try a quick &#8216;What am I?&#8217;. Is this picture..:</p><p>a). An Imperial Star Destroyer from Star Wars?</p><p>b). A Lego model of the Wankel Rotary Engine?</p><p>c). A scientific calculator?</p><p>If you answered &#8216;<em><strong>C &#8211; a calculator</strong></em>&#8216;, give yourself a big smiley-face stamp! You are looking at a fully-functional, scientific calculator, built entirely within the virtual world of <a
href="http://www.minecraft.net/">Minecraft</a>.</p><p>Now, Minecraft — if you&#8217;re not familiar with it — is an online construction play-world with a very 8-bit aesthetic. Think &#8216;virtual Lego&#8217;.</p><p>Most Minecrafters spend their time constructing elaborate palace/fortresses. Sometimes these structures include the relatively rare &#8216;redstones&#8217;, which can be used as simple switches to control doors, gates and the like.</p><p>In the example above, a 16 year old (&#8216;MaxSGB&#8217;) has wired together <a
href="http://www.tomshardware.com/news/Minecraft-Calculator-Graphing-MaxSGB-Scientific,15109.html">a virtual mountain of redstone into a stadium-sized, working calculator </a>—complete with graphing abilities, sine, cosine, tan and square root functions.<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><p>If you&#8217;re having trouble getting your head around this, imagine a kid building his own Playstation II from Lego Mindstorm – you&#8217;re getting close.</p><p>Amazing. Crazy. Ridiculous. Tenacious. I&#8217;m not sure which is the best description.</p><p>Is this a good calculator?</p><p>No. The reality is, I had a digital watch in Grade 5 that had a better, built-in calculator than this creation.</p><p>But that&#8217;s not the point.</p><p>By pushing the boundaries, we can only guess at how much this guy has taught himself along the way &#8212; lessons in everything from architecture to engineering to programming to electronics to just raw problem-solving.</p><h2>The Plan</h2><p>With this idea of pushing things until they shudder in pain, we&#8217;re going to do something equally silly with CSS — construct a playable game &#8211; <a
href="http://en.wikipedia.org/wiki/Pong">Pong (1972)</a>. No JavaScript or Flash. Just HTML, CSS and a healthy dollop of nutty professor.</p><p>Along the way we&#8217;ll:</p><ol><li>do some interesting stuff with CSS animation</li><li>fiddle with CSS3 sibling selectors</li><li>hopefully have a chuckle about the ingenuity/insanity we employ</li></ol><p>We&#8217;re going to be using a lot of very modern CSS3. In theory, it *should* work in Firefox, Opera and Safari but I&#8217;m only going to guarantee Chrome for this code demo.</p><p>I&#8217;m also only going to quote the official W3C version of the CSS in the examples to keep the code de-cluttered, &#8212; though real-world browsers will need their prefixes (-moz, -webkit, etc..).</p><p>Most of my demo code uses <a
href="http://leaverou.github.com/prefixfree/">prefixfree</a> to add the appropriate browser-specific prefixes at runtime, but you might prefer <a
href="http://compass-style.org/">Compass</a>, <a
href="http://fireapp.handlino.com/">Fire</a>, <a
href="http://mhs.github.com/scout-app/">Scout</a>, <a
href="http://sass-lang.com/">Sass</a>, <a
href="http://lesscss.org/">Less</a> or even hard-coding your own hand &#8216;prefixerated&#8217; CSS.</p><p>If you want to know what we&#8217;re heading towards, <a
href="http://cssdeck.com/labs/css3-pong-with-scoring">here&#8217;s the final demo</a>.</p><h2>Part 1 &#8211; The Animation</h2><h3>1). Setting up the court</h3><p>First, let&#8217;s set up a court and ball to play with.</p><p>Here&#8217;s our starting markup:</p><pre class="brush: xml; title: ; notranslate">
&lt;h1&gt;CSS PONG&lt;/h1&gt;
&lt;div id=&quot;court&quot;&gt;
    &lt;div id=&quot;horizontal&quot;&gt;
	&lt;span id=&quot;ball&quot;&gt;&lt;/span&gt;
    &lt;/div&gt;
&lt;/div&gt;
</pre><p>The outer #court DIV defines our playing court. We&#8217;ll give it a dashed green border like the original game.</p><p>We have a #ball which sits inside a wrapping DIV called #horizontal, which runs the full width of the court. This invisible DIV will become a useful platform from which to hang other screen elements later.</p><pre class="brush: css; title: ; notranslate">
#court{
	margin: 30px auto;
	width: 600px;
	height: 300px;
	position: relative;
	border: 4px dotted #3f3;
</pre><p>Our #court needs a net. We can use a &#8216;:before&#8217; pseudo element to attach it to our court.</p><pre class="brush: css; title: ; notranslate">
#court:before {
	left: 50%;
	content:'';
	width: 10px;
	height: 300px;
	position: absolute;
	border-left: 4px dashed #3f3;
	}
</pre><p>Our ball is a simple 20px by 20px round-cornered DIV. No external image required.</p><pre class="brush: css; title: ; notranslate">
#ball {
	position: absolute;
	width: 20px;
	height: 20px;
	display: block;
	background :#3f3;
	border-radius: 50%;
	transform: translate3d(10px,0,0) }
</pre><p><img
class="aligncenter size-full wp-image-8722" src="http://designfestival.com/files/2012/05/step0.png" alt="" width="403" height="274" /></p><p>We now have our starting structure.</p><h3>2). Animating the ball</h3><p>Let&#8217;s back up a bit. If you&#8217;re already a CSS animation wizard, feel free to jump down page to <a
href="#btp">Back to Pong</a>. If not, we&#8217;ll dash through a few general &#8216;need to knows&#8217;.</p><p>First, most &#8212; but NOT ALL &#8212; CSS properties are &#8216;animatable&#8217;. As a general rule, if you can describe it with a number, it <em>should</em> be animatable.</p><p>For instance, we <strong>CAN</strong> animate:</p><ul><li><code>left: 0px  &rarr; left: 100px</code></li><li><code>margin-top: 10%  &rarr; margin-top:90%</code></li><li><code>opacity: 0  &rarr;  opacity: 1</code></li><li><code>z-index: 1 &rarr; z-index: 99</code></li></ul><p>However, we <strong>CAN&#8217;T</strong> animate:</p><ul><li><code>float: left   &rarr; float: right</code></li><li><code>display: block  &rarr;  display: none</code></li><li><code>visibility: hidden  &rarr;  visibility: visible</code></li></ul><p>You&#8217;ll notice that second group consists of discrete &#8216;states&#8217;. There are no inbetween states &#8212; like &#8216;slightly-hidden&#8217; or &#8216;a little bit block&#8217;, which is why you can&#8217;t animate those properties.</p><p>Thankfully colors are always easy to animate — even when you use exotic keywords such as &#8216;dark orchid&#8217; or &#8216;cornflower blue&#8217; — because your browser automatically converts them into numbers.</p><p>But there&#8217;s more to consider.</p><p>Often, we&#8217;ll want to move things around on screen, and there are many ways do to that. In theory, animating any of the these properties would work:</p><ul><li><code>left</code></li><li><code>right</code></li><li><code>top</code></li><li><code>bottom</code></li><li><code>margin</code></li><li><code>padding</code></li><li><code>transform:translate(<em>x,y</em>)</code></li><li><code>transform:translate3d(<em>x,y,z</em>)</code></li></ul><p>While they all work, surprisingly, there are BIG differences in how browsers handle them.</p><p>Believe it or not, <code>translate3d()</code> is the most efficient method to move objects with CSS3 — even if you&#8217;re only animating 2d objects!</p><p>Apparently, <code>translate3d()</code> offloads the animation grunt-work onto the graphics processor, which speeds things up considerably. Certainly, my MacBook Pro processor stayed much cooler when I use <code>translate3d()</code>.</p><p>The takeaway: Try to use <code>translate3d()</code> whenever you’re moving stuff around the screen.<br
/> <a
name="btp"></a><br
/> &nbsp;<br
/> <b>Back to Pong.</b></p><p>Let&#8217;s take what we know about <code>translate3d()</code>, and give our ball a simple left-to-right-and-back bounce.</p><p>The <code>transform:translate3D</code> asks us for three values — X, Y and Z. Animating X moves objects left and right, while animating Y moves things up and down. We can leave the Z value at 0.</p><p>Let&#8217;s create a &#8216;leftright&#8217; animation and apply it to our #ball.</p><pre class="brush: css; title: ; notranslate">
@keyframes leftright {
0%,100% {transform: translate3d(10px,0,0)}
50% {transform: translate3d(570px,0,0)}
}
#ball{
 ...
 animation: leftright 2s infinite linear
 }
</pre><p>The ball should now bounce from left to right in our #court DIV every two seconds.</p><div
id="attachment_8387" class="wp-caption aligncenter" style="width: 403px"> <img
class="size-full wp-image-8387" src="http://designfestival.com/files/2012/05/step1.png" alt="" width="403" height="277" /><p
class="wp-caption-text">Step 1: setting up the court</p></div><p>Now let&#8217;s create a new animation called &#8216;updown&#8217; — you can guess what that does — and apply it to our #horizontal platform.</p><pre class="brush: css; title: ; notranslate">
@keyframes updown {
 0%,50%,100% {transform: translate3d(0,0,0)}
 25% {transform: translate3d(0,142px,0)}
 75% {transform: translate3d(0,-136px,0)} }
 #horizontal{
 ...
 animation: updown 2s infinite linear; }
 </pre><p><img
src="http://designfestival.com/files/2012/05/step2.png" alt="" width="406" height="284" /></p><p><a
href="http://www.sitepoint.com/examples/css3pong/step2">Here&#8217;s what we have so far</a>.</p><p>As you can see, our ball completes a perfect, diamond-shaped loop of the court, every two seconds.</p><p>Nice &#8230; but it quickly becomes boring.</p><p>What happens if we make a tiny tweak to the animation timing? Instead of 2.0 seconds, let&#8217;s set the #ball to cycle every 1.9 seconds and the #horizontal platform animation to 2.3 seconds.</p><p><img
class="alignright size-full wp-image-8506" src="http://designfestival.com/files/2012/05/step3.png" alt="Changing up the timing on our animations makes the path much more interesting" width="408" height="286" /></p><p><a
href="http://www.sitepoint.com/examples/css3pong/step2-a.html">Here&#8217;s the result</a>.</p><p>As you can see, that small timing change has a large effect on the ball&#8217;s path. It&#8217;s true, this path <em>WILL</em> repeat, but instead of a two-second repeat cycles, it&#8217;s now on a 46 second cycle.</p><p>A much more interesting result.</p><h3>Adding players</h3><p>Lets add some players to the mix. We&#8217;ll pop in two new SPANs inside our platform (#player1 and #player2) and position them at either end.</p><pre class="brush: xml; title: ; notranslate">&lt;h1&gt;CSS PONG&lt;/h1&gt;&lt;div id=&quot;court&quot;&gt;
 &lt;div id=&quot;platform&quot;&gt;
     &lt;span id=&quot;ball&quot;&gt;&lt;/span&gt;
         &lt;span id=&quot;player1&quot;&gt;&lt;/span&gt;
         &lt;span id=&quot;player2&quot;&gt;&lt;/span&gt;
    &lt;/div&gt;
 &lt;/div&gt;
</pre><pre class="brush: css; title: ; notranslate">#player1, #player2 {
 background:#3f3;
  position:absolute;
  width:7px;
  height:44px;
  left:4px;
  margin-top:-12px;
}
#player2{right:4px}
</pre><p><a
title="Step 3: adding players" href="http://www.sitepoint.com/examples/css3pong/step3-a.html">Here&#8217;s a working demo</a>.</p><p>As the players are contained inside our moving platform, they really CAN&#8217;T HELP but perfectly track the ball from top to bottom.</p><p>But we <em><strong>know</strong></em> that real players don&#8217;t play like that. They twitch. They lunge. They dive. They scramble.</p><p>What if we create a new &#8216;twitchy’ animation keyframe that makes the bats twitch erratically — relative to the platform?</p><pre class="brush: css; title: ; notranslate">@keyframes twitchy { /* make player twitch like a real player  */
  0%,
  100%{transform: translate3d(0, 0px, 0); }
  20% {transform: translate3d(0, -45px, 0); }
  44% {transform: translate3d(0, 25px, 0); }
  46% {transform: translate3d(0, -15px, 0); }
  48% {transform: translate3d(0, 15px, 0); }
  50% {transform: translate3d(0, 50px, 0); }
  70% {transform: translate3d(0, 60px, 0); }
  85% {transform: translate3d(0, -30px, 0); }
  95% {transform: translate3d(0, 30px, 0); }
}
#player1, player#2{ animation: leftright 2.3s infinite linear; }
#player1 {animation-delay:1.15s} /* delay player 2 for half a cycle */
</pre><p>Now, as long as we keep the bat animation on the same timing as the &#8216;leftright&#8217; ball animation, they should always meet the ball between twitches.</p><p><a
href="http://www.sitepoint.com/examples/css3pong/step3" title="Twitchy players">Let’s put that into the demo (in ESPN super slo-mo!). </a></p><p>That&#8217;s an improvement. The bats twitch to-and-fro like a couple of 7-year olds on too much red cordial.</p><p>So, at this point we have an interesting animation example, but it&#8217;s no game.</p><h2>Part 2: Making it Playable &#8230; kinda</h2><p>&#8216;<em>Hey, wouldn&#8217;t it be cool if you could actually play it?</em>&#8216;</p><p>That was Casey&#8217;s first comment when he saw the animation experiment. I laughed and shrugged at the time, but it <em><strong>did</strong></em> get me thinking over the next few days.</p><p>Obviously the difference between a game and an animation is <em>interactivity</em>. If I&#8217;m not using JavaScript, I need a way for my CSS to interact with the user. I listed all the built-in &#8216;user events&#8217; that CSS could tap into.</p><ul><li><code>:hover</code></li><li><code>:active</code></li><li><code>:visited</code></li><li><code>:checked</code></li><li><code>:focus</code></li><li><code>:enabled</code></li><li><code>:disabled</code></li><li><code>:selection</code></li><li><code>:target</code></li></ul><p>Maybe we could somehow piggyback on one of these events? I decided <code>:hover</code> was my best chance, so our cursor will become our bat.</p><pre class="brush: css; title: ; notranslate">
#court {
cursor: url(/bat.gif), text;
}
</pre><p>Next, we need a new element that will act as our trigger for the animation. I&#8217;m going to insert a DIV called &#8216;#targetzone&#8217; just before our #horizontal platform. We can lose the automated player #1 too.</p><pre class="brush: xml; title: ; notranslate">&lt;h1&gt;CSS PONG&lt;/h1&gt;
   &lt;div id=&quot;court&quot;&gt;
	&lt;div id=&quot;court&quot;&gt;
        &lt;span id=&quot;targetzone&quot;&gt;&lt;/span&gt;
	&lt;div id=&quot;horizontal&quot;&gt;
            &lt;span id=&quot;ball&quot;&gt;&lt;/span&gt;
	    &lt;span id=&quot;player2&quot;&gt;&lt;/span&gt;
	&lt;/div&gt;
  &lt;/div&gt;
</pre><pre class="brush: css; title: ; notranslate">
#targetzone {
  background: rgba(0,0,255,0.25);
  position: absolute;
  margin:-50% 0 0 -50%;
  z-index:100;
  width:800px;
  height:600px;
}
</pre><p>The CSS &#8216;sibling selectors&#8217; &#8212; the <code>+</code> and the <code>~</code> &#8212; are quite powerful, yet often overlooked. In this case, we can use them to pass a <code>:hover</code> state from one HTML element to the element next to it. This let&#8217;s us use #targetzone to trigger our animation.</p><p>So, we&#8217;ll need to remove all of our current animations and transfer them to new &#8216;hover triggered&#8217; rules like this:</p><pre class="brush: css; title: ; notranslate">
#targetzone:hover{
    animation: updown 2.3s infinite linear;
}
#targetzone:hover + #horizontal{
    animation: updown  2.3s infinite linear;
}
#targetzone:hover + #horizontal #player2{
    animation: twitchy 1.9s infinite linear;
    animation-delay:0.95s;
}
#targetzone:hover + #horizontal #ball{
    animation: leftright 1.9s infinite linear;
}
</pre><p>Now our animation only plays when the cursor hovers over this #targetzone &#8212; I&#8217;ve made #targetzone semi-transparent blue for the demo, but it would normally be invisible to the player.</p><p><a
href="http://www.sitepoint.com/examples/css3pong/step4">Like this</a>. We&#8217;re getting closer.</p><p>Now, let&#8217;s think about ANY real-world game of tennis.</p><p>The funny thing about tennis is: most of the time the game doesn&#8217;t NEED you.</p><p>You can&#8217;t catch, dribble or carry the ball. For 98% of the each point, the ball is travelling (or animating) across the court, well out of your reach or direct influence.</p><p>For literally micro-seconds each rally you have a chance to either hit the ball back, or make a mistake.</p><p>So, if you broke it down into steps, our tennis logic could be written as:</p><p>1) BEGIN: ball animation.<br
/> 2) ANIMATE: ball to the opponent. IGNORE player<br
/> 3) ANIMATE: ball back to player. IGNORE player<br
/> 4) CHECK: player&#8217;s cursor position<br
/> 5) IS PLAYER BLOCKING BALL&#8217;S PATH?<br
/> 5) IF: YES &#8211; GOTO: Step #2<br
/> 6) IF: NO &#8211; END animation &amp; SCORE 1 for computer.</p><p>So, if, as the ball nears the baseline, we were to quickly shrink our #targetzone trigger to the area just in front of the ball, the player would have to be on that spot for the animation to continue. We&#8217;d have some sort of very, very rudimentary CSS ‘collision detection’.</p><p>Here&#8217;s the new keyframe animation to resize the #targezone.</p><pre class="brush: css; title: ; notranslate">
@keyframes targetzone {
  /* ball is in general play - targetzone is big */
  0%, 96% {
    width: 800px;
    height: 600px;
    margin: -50% 0 0 -50%;
  }
  /* ball is approaching player 1's baseline - targetzone shrinks*/
  96.1%, 100% {
    width: 150px;
    height: 100px;
    top: 0;
    left: 0;
    margin: 10% 0 0 -50px;
  }
}
</pre><p>Using a comma, we can add this new animation to our #targetzone trigger.</p><pre class="brush: css; title: ; notranslate">
#targetzone:hover {
  animation:
    updown 2.3s infinite linear,
    targetzone 1.9s infinite linear;
}
</pre><p><a
href="http://www.sitepoint.com/examples/css3pong/step5">Here&#8217;s the result.</a></p><p>It&#8217;s essentially working as planned, but with one issue.</p><p>The microsecond any player misses the ball (and the hover state ends), #targetzone resets and instantly re-triggers the animation to start again. You have to be paying close attention to even notice that the point ended.</p><p>We need one more animation to force a short break between points (like real tennis). This animation will play through just once (rather than loop) for each new rally, and will reshape #targetzone from <code>height: 0</code> through to <code>height: 150px</code>.</p><pre class="brush: css; title: ; notranslate">
@keyframes preparetoserve {
  /* Give targetzone no height so trigger is hidden */
  0%, 90% {
    height: 0px;
  }
  /* after a short time, resize the targetzone, ready to serve*/
  90.1%, 100% {
    height: 100px;
   }
}
</pre><p>We can attach it directly to #targetzone because we don&#8217;t need the player to trigger it.</p><pre class="brush: css; title: ; notranslate">
#targetzone {
  ...
  animation: preparetoserve 2s 1 linear;
}
</pre><p><a
href="http://www.sitepoint.com/examples/css3pong/step6"><br
/> Let&#8217;s add this to the demo.</a></p><p>It&#8217;s taking shape!</p><h3>Part 3: Keeping Score</h3><p>As Oscar Wilde said, ‘Nothing succeeds like excess’ so why stop now? This puppy needs a CSS-powered scoring system, goshdarnit!</p><p>Now, rather than breaking down every line of code — it’s already a lengthy post — I’m going to talk you through the general principle and leave you to pull the demo apart if you’re interested.</p><h3>Maintaining State with HTML &amp; CSS</h3><p>To update any scoreline, we need a way to use HTML/CSS to ‘maintain state’ — to keep track of what has happened so far. This is usually handled by servers and cookies.</p><p>A couple of years ago, Lea Verou wrote a really fun article on using restyled checkboxes to <a
href="http://lea.verou.me/2011/06/pure-css-tic-tac-toe/" title="Pure CSS Tic Tac Toe">build a CSS-powered Tic-tac-toe game</a>. It showed how HTML forms can record mouse clicks and how CSS can instantly respond to those clicks. She also showed that HTML form elements didn&#8217;t have to look like HTML form elements.</p><p>I thought it was super clever stuff.</p><p>So, what if:</p><p>1). I replaced my single #targetzone SPAN with a series of five HTML radio buttons — one for each scored point (1-5)? With a little CSS re-jigging, I could make our animation require that the radio button was both checked AND hovered over (i.e. <code>input:checked:hover</code>).</p><p>2). I also linked the scoreboard display to which of these inputs is checked? The scoreboard would tick over as soon as Player 1 clicks to serve. Yes, the sad truth is, the computer currently CAN’T lose this game &#8212; so the only real question is <em>&#8216;How long will it be until Player 1 (you) misses the ball?</em>&#8216;.</p><p>I know, this feels unfair when you find out. It is.</p><p>Of course, for the sake of theatre, we want our player to *think* they have a chance of winning. The fact is, we can only update our radio button scoreboard when a click happens, and there are no clicks when someone misses the ball.</p><p>This means I have to update the score on the service click, but somehow not let the player SEE that new score until the point ends. Hmmm &#8230;</p><p>3). So, what if I position the new score just out of view <em>while the hover is in place</em>? Like jamming open an old window pane with a pencil, the window will come slamming down as soon as we pull out the pencil. In our case, removing the hover will bring our new score crashing down into place.</p><p>A CSS transition makes the new score slide into place smoothly.</p><p>I didn&#8217;t say it was pretty.</p><p>But it works.</p><p><a
href="http://cssdeck.com/labs/css3-pong-with-scoring" title="CSS3 Pong - Final">Here&#8217;s the CSSDeck version of the final code. </a></p><p>Feel free to poke around in there.</p><h3>Issues, Caveats, and Challenges</h3><p>1). You may have already accidently discovered this. If you don’t move your cursor, the ball will be returned — EVEN IF YOU AREN&#8217;T ANYWHERE NEAR IT.</p><p>Unfortunately, this is just a fundamental property of the way browsers work and I doubt there is any way to code around it (without using JavaScript, anyway).</p><p>Essentially, every time you move your cursor — even the tiniest amount — your browser fires off the question &#8216;Hey, are there any new hover events happening??&#8217; If the answer is yes, it renders some new CSS.</p><p>However, if the mouse doesn&#8217;t move, the browser simply doesn’t ask that question—even if other elements have moved in relation to the cursor. I can’t think how you could possibly change that behavior (without JavaScript).</p><p>But hey, stop cheating, and just keep the bat moving, OK?!</p><p>2). I&#8217;d love to be able to limit the movement of the player#1 bat to strictly up and down. If you can figure a way to pull it off, I bestow great glory unto you, sir or madame!</p><p>3). I have a vague idea it might be possible to allow the robot player lose sometimes. If we set a limit on the animation &#8212; let&#8217;s say 20-25 iterations &#8212; and the human player lasted that long, we could let them win.</p><p>However, scoring it correctly is the tough part. How do we tell whether someone outlasted the bot, and adjust the score accordingly? I&#8217;ve put some thought into this, but it&#8217;s hurting my brain.</p><p>If you&#8217;re inclined, feel free to fork it on CSSDeck and have a go.</p><h3>Final word</h3><p>So, are we at the shiny new dawn of the CSS3 Games era?</p><p>Um &#8230; no.</p><p>Just to clarify. No.</p><p>This wasn&#8217;t just a hack. It was a glittering city of hacks built on the banks of the ol&#8217; Hack River. On the Planet Hack.</p><p>So, why bother?</p><p>The fun for me was asking CSS do something that it’s not in any way designed to do. It was quite hard to do something that would be relatively simple with other languages. It was just a fun problem to think about in my play time. Like sudoku or Rubik’s cube.</p><p>Secondly, like the Minecraft guy, there are some things you can only truly learn by pushing outside the boundaries of what you normally do. I had to force myself to really look at the CSS spec with fresh eyes for the first time in a long time.</p><p>With any luck, this article will give some people ideas about using CSS in ways that might not have occurred to them otherwise.</p><p>Also, if you made it this far, I thank you for your patience! I tried to keep this short but there was a lot to explain.</p><p>* So, what do you think?<br
/> * Got an improvement?<br
/> * Got a question?<br
/> * Got an idea for a CSS3-powered World of Warcraft?</p><div
class='after-content-widget-1'><div
id="sitepointcontextualcontentmanagerwidget-5" class="widget widget_sitepointcontextualcontentmanagerwidget"><style>#targettedEOF { width: 99%; font-family: "Open Sans", Helvetica, Arial, sans-serif; border-radius: 4px; border: 1px dotted #47B4DC; }
#targettedEOF .targettedEOFcol { float: left; padding: 20px; }
#targettedEOF .targettedEOFbtn { clear: both; padding: 0; }
#targettedEOF h2 { margin-top: 10px; }
#targettedEOF .sptolbCTA { border: 0 none; border-bottom: 2px solid #85bb41; background-color: #91c352; color: white; margin: 0; padding: 1em 1em; border-radius: 4px; vertical-align: middle; text-align: center; font-weight: 700; font-size: 17px; display: inline-block; line-height: 0; text-shadow: -1px -1px 1px rgba(0,0,0,0.2); cursor: pointer; text-decoration: none;
}
#targettedEOF .sptolbCTA:hover { color: white; }
#targettedEOF .targettedEOFbtn p { padding: 0; margin: 0; }
.cat_javascript #targettedEOF h2, .cat_cloudspring #targettedEOF h2 { font-size: 1.267em; line-height: 1.158em; margin: 1.737em 0 0.579em 0; font-weight: bold; color: #0071D8; }
.cat_javascript #targettedEOF, .cat_cloudspring #targettedEOF { font-size: 1.5em; line-height: 1.467em; width: 100%; }
.cat_javascript #targettedEOF ul, .cat_cloudspring #targettedEOF ul { list-style: square; margin: 0 0 1.467em 1.467em; }</style><div
id="targettedEOF"><div
class="targettedEOFcol"> <a
href="https://learnable.com/books/jsjavascript1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=UltimateJavaScriptBundle"><img
src="https://learnable-images.s3.amazonaws.com/books/responsive1_medium.jpg" width="145"></a></div><div
class="targettedEOFcol"><h2>Learn Responsive Web Design</h2><ul><li>SitePoint's ebook: <a
href="https://learnable.com/books/responsive1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Jump Start Responsive Web Design</a></li><li><a
href="https://learnable.com/courses/responsive-web-design-key-concepts-2759?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Responsive Web Design: Key Concepts</a> online course</li><li>Unlimited access to <a
href="https://learnable.com/topics/front-end?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign"> SitePoint Premium Content</a></li></ul><p><a
class="sptolbCTA" href="https://learnable.com/?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign#pricing">Join Learnable $29</a> <span><strong>Includes all SitePoint books</strong></span></div><div
class="targettedEOFbtn"></div></div><div
class="dfp-ad show-desktop"><div
id="div-gpt-ad-1340873946991-4" style="width: 728px; height: 90px;"> <script type="text/javascript">googletag.cmd.push(function() { googletag.display("div-gpt-ad-1340873946991-4"); });</script> </div></div></div></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=LOy2lsgO0OM:XLCRpA8oJi4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=LOy2lsgO0OM:XLCRpA8oJi4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=LOy2lsgO0OM:XLCRpA8oJi4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?i=LOy2lsgO0OM:XLCRpA8oJi4:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SitepointFeed/~4/LOy2lsgO0OM" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/css3-pong-insane-things-to-do-with-css/feed/</wfw:commentRss> <slash:comments>18</slash:comments> <feedburner:origLink>http://www.sitepoint.com/css3-pong-insane-things-to-do-with-css/</feedburner:origLink></item> <item><title>Windows 8.1: Back to Basics?</title><link>http://feedproxy.google.com/~r/SitepointFeed/~3/L35PGBWyFp4/</link> <comments>http://www.sitepoint.com/windows-blue-8-1/#comments</comments> <pubDate>Mon, 13 May 2013 13:12:06 +0000</pubDate> <dc:creator>Craig Buckler</dc:creator> <category><![CDATA[Operating systems]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Usability]]></category> <category><![CDATA[microsoft]]></category> <category><![CDATA[OS]]></category> <category><![CDATA[windows]]></category> <category><![CDATA[Windows 8]]></category> <guid isPermaLink="false">http://www.sitepoint.com/?p=66127</guid> <description><![CDATA[Craig discusses the web speculation around Windows Blue/8.1 and IE11. Will the new OS address user concerns?]]></description> <content:encoded><![CDATA[<p></p><p>Microsoft has been in the news this week. While any publicity is better than none, the headlines and statements have been particularly scathing:</p><ul><li>Windows 8 is Microsoft&#8217;s &#8220;New Coke&#8221; fiasco</li><li>Windows 8 sales slump is killing the PC industry</li><li>users are confused by Windows 8</li></ul><p>Windows 8 was an ambitious project. The OS attempted to merge smart phone, tablet and desktop concepts into a cohesive experience. Microsoft should be applauded for trying something new but, in reality, Windows 8 is two OSs bundled as one.</p><p>Tami Reller, head of Windows Marketing and Finance, admitted:</p><blockquote><p>the learning curve is definitely real</p></blockquote><p>Few would disagree. I&#8217;ve been using the OS for seven months and, while it feels comfortable now, those initial weeks without a Start button were disorientating. Metro can be &#8212; <em>and still is</em> &#8212; quirky on a standard desktop PC, but I rarely use Metro apps other than the media player.</p><p>If you&#8217;re in the industry, you&#8217;re paid to use technology for its own sake; learning something new is part of the course. However, for most companies, technology is a tool which helps them achieve business objectives. Unless there are clear commercial benefits, the costs associated with changing that tool and retraining staff are prohibitive.<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><p>I suspect people new to PCs actually grasp Windows 8 concepts better than older versions of the OS <em>(clicking Start to shut down was an obvious metaphoric breakdown)</em>. Unfortunately, most people <strong>have</strong> used Windows before; they can understand evolution but revolution is a different matter. Besides, if you absolutely must learn something new, why not try Mac OS or Linux?</p><h2>Windows Blue</h2><p>It&#8217;s impossible to determine figures but I&#8217;d be amazed if Windows 8 sales matched those of Windows 7. Fortunately, Microsoft has listened to user criticism.</p><p>Pre-release versions of the next version of the OS, codenamed Windows Blue, were leaked on to the web recently. Microsoft won&#8217;t make any public comments, but hinted a preview release could appear in June. Version 8.1 is the most likely name but many of us old hands will think of it as Service Pack 1.</p><p>The interface looks much the same, but the leaked OS offers a number of revised features&hellip;</p><p><strong>An optional Start button</strong><br
/> In my <a
href="/windows-8-review-3/">Windows 8 review</a> I speculated:</p><blockquote><p>I would not be surprised to see the Start button make a triumphant return</p></blockquote><p><a
href="http://blogs.sitepointstatic.com/images/tech/825-windows-blue-screen.png"><img
src="http://blogs.sitepointstatic.com/images/tech/825-windows-blue-screen.png" width="600" alt="Windows 8 and Start button" class="center" /></a></p><p>I rarely miss the Start button now I&#8217;ve created appropriate taskbar shortcuts and use the keyboard Windows key to access the Start screen. The new logo-shaped Start button will probably do the same as the lower-left screen gesture, but having a button present will reassure many people.</p><p><strong>Boot to desktop</strong><br
/> Microsoft was criticized for showing the Start screen rather than the more familiar desktop after login. It&#8217;s a minor point since launching any standard application will instantly switch. That said, a new &#8220;boot to desktop&#8221; option will bring joy to many.</p><p><strong>Configurable tile sizes</strong><br
/> Start screen tiles are currently either &#8220;larger&#8221; or &#8220;smaller&#8221;. Even the small size doesn&#8217;t permit many icons on a desktop display so a new icon-sized tile will use a quarter of the space. Interestingly, a new super-sized option may also appear which could provide some interesting possibilities for live tiles.</p><p><strong>New apps</strong><br
/> Many of the existing Metro apps will be updated and a new video editing application could appear.</p><p>The OS should also include better SkyDrive integration. I&#8217;ve been impressed with Microsoft&#8217;s DropBox-like online file storage system and I suspect an increased number of applications will be SkyDrive-aware.</p><p><strong>Internet Explorer 11</strong><br
/> IE11 is a more exciting prospect although there&#8217;s no guarantee it&#8217;ll reach the final build. If expectations are correct, the new browser will fill the final missing gaps in IE10 &#8212; namely a few minor HTML5 features and WebGL <em>(it&#8217;ll be interesting to hear how Microsoft engineers overcame the <a
href="http://www.sitepoint.com/internet-explorer-10-review-ie10/">WebGL &#8220;security issues&#8221;</a> they identified)</em>.</p><p>A long-overdue update to the F12 Developer Tools could also appear&hellip;</p><p><img
src="http://blogs.sitepointstatic.com/images/tech/825-windows-blue-ie11-tools.png" width="600" alt="IE11 F12 Developer Tools" class="center" /></p><p>The current tools are adequate but clunky and ugly when compared with Firebug, the Webkit Inspector, Dragonfly or any other Microsoft development software. The company is enticing users back to IE but projects such as <a
href="http://modern.ie/">modern.IE</a> a solid set of development tools will get developers on-side.</p><p>In summary, Windows 8 is changing but don&#8217;t expect it to revert back to Windows 7. Time will tell if the updates are enough to convince buyers.</p><p>Are you using Windows 8? Do you prefer it? Do you detest it? Do you want your Start button back? Will Windows 8.1 address your concerns?</p><div
class='after-content-widget-1'><div
id="sitepointcontextualcontentmanagerwidget-5" class="widget widget_sitepointcontextualcontentmanagerwidget"><style>#targettedEOF { width: 99%; font-family: "Open Sans", Helvetica, Arial, sans-serif; border-radius: 4px; border: 1px dotted #47B4DC; }
#targettedEOF .targettedEOFcol { float: left; padding: 20px; }
#targettedEOF .targettedEOFbtn { clear: both; padding: 0; }
#targettedEOF h2 { margin-top: 10px; }
#targettedEOF .sptolbCTA { border: 0 none; border-bottom: 2px solid #85bb41; background-color: #91c352; color: white; margin: 0; padding: 1em 1em; border-radius: 4px; vertical-align: middle; text-align: center; font-weight: 700; font-size: 17px; display: inline-block; line-height: 0; text-shadow: -1px -1px 1px rgba(0,0,0,0.2); cursor: pointer; text-decoration: none;
}
#targettedEOF .sptolbCTA:hover { color: white; }
#targettedEOF .targettedEOFbtn p { padding: 0; margin: 0; }
.cat_javascript #targettedEOF h2, .cat_cloudspring #targettedEOF h2 { font-size: 1.267em; line-height: 1.158em; margin: 1.737em 0 0.579em 0; font-weight: bold; color: #0071D8; }
.cat_javascript #targettedEOF, .cat_cloudspring #targettedEOF { font-size: 1.5em; line-height: 1.467em; width: 100%; }
.cat_javascript #targettedEOF ul, .cat_cloudspring #targettedEOF ul { list-style: square; margin: 0 0 1.467em 1.467em; }</style><div
id="targettedEOF"><div
class="targettedEOFcol"> <a
href="https://learnable.com/books/jsjavascript1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=UltimateJavaScriptBundle"><img
src="https://learnable-images.s3.amazonaws.com/books/responsive1_medium.jpg" width="145"></a></div><div
class="targettedEOFcol"><h2>Learn Responsive Web Design</h2><ul><li>SitePoint's ebook: <a
href="https://learnable.com/books/responsive1?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Jump Start Responsive Web Design</a></li><li><a
href="https://learnable.com/courses/responsive-web-design-key-concepts-2759?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign">Responsive Web Design: Key Concepts</a> online course</li><li>Unlimited access to <a
href="https://learnable.com/topics/front-end?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign"> SitePoint Premium Content</a></li></ul><p><a
class="sptolbCTA" href="https://learnable.com/?utm_source=SitePoint&utm_medium=EndofArticleTargetedPlacement&utm_campaign=LearnResponsiveWebDesign#pricing">Join Learnable $29</a> <span><strong>Includes all SitePoint books</strong></span></div><div
class="targettedEOFbtn"></div></div><div
class="dfp-ad show-desktop"><div
id="div-gpt-ad-1340873946991-4" style="width: 728px; height: 90px;"> <script type="text/javascript">googletag.cmd.push(function() { googletag.display("div-gpt-ad-1340873946991-4"); });</script> </div></div></div></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=L35PGBWyFp4:O5p4OloVx14:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=L35PGBWyFp4:O5p4OloVx14:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/SitepointFeed?a=L35PGBWyFp4:O5p4OloVx14:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/SitepointFeed?i=L35PGBWyFp4:O5p4OloVx14:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/SitepointFeed/~4/L35PGBWyFp4" height="1" width="1"/>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/windows-blue-8-1/feed/</wfw:commentRss> <slash:comments>49</slash:comments> <feedburner:origLink>http://www.sitepoint.com/windows-blue-8-1/</feedburner:origLink></item> </channel> </rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 12/42 queries in 0.042 seconds using memcached
Object Caching 1873/1931 objects using memcached

Served from: www.sitepoint.com @ 2013-05-21 06:58:54 -->
