<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Engineered Web]]></title>
  <link href="http://engineeredweb.com/atom.xml" rel="self"/>
  <link href="http://engineeredweb.com/"/>
  <updated>2012-05-15T23:07:50-04:00</updated>
  <id>http://engineeredweb.com/</id>
  <author>
    <name><![CDATA[Matt Farina]]></name>
    <email><![CDATA[matt@mattfarina.com]]></email>
  </author>

  
  <entry>
    <title type="html"><![CDATA[Drupal 7.14 API Compatibility Breaking Change]]></title>
    <link href="http://engineeredweb.com/blog/drupal-7-14-api-incompatible-change"/>
    <updated>2012-05-15T20:30:00-04:00</updated>
    <id>http://engineeredweb.com/blog/drupal-7-14-api-incompatible-change</id>
    <content type="html"><![CDATA[<p>Minor <a href="http://drupal.org">Drupal</a> versions are usually for bug fixes, security updates, and the occasional new feature that doesn't break backwards compatibility. Compatibility changes are reserved for major Drupal releases. There are exceptions such as Drupal 6.2. It was such a big deal there is an <a href="http://drupal.org/node/244569">update documentation page just for this release</a>. When Drupal 7.14 made an API breaking change <a href="http://drupal.org/update/modules">without providing documentation</a> or notification to module developers I was quite surprised. The lack of detail made it difficult to track down the changes when I had a broken codebase. Here are the details so others can, hopefully, have an easier time if they run into this problem.</p>
<p><a href="http://engineeredweb.com/blog/drupal-7-14-api-incompatible-change">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Speedy 1.0 Released]]></title>
    <link href="http://engineeredweb.com/blog/speedy-1-released"/>
    <updated>2012-05-07T15:30:00-04:00</updated>
    <id>http://engineeredweb.com/blog/speedy-1-released</id>
    <content type="html"><![CDATA[<p>Minifying the JavaScript distributed to a browser is <a href="http://engineeredweb.com/blog/why-minify-javascript/">important for performance</a>. The <a href="http://drupal.org/project/speedy">speedy module</a> came into being in an effort to make this easy for Drupal sites to implement everywhere. Today the 1.0 release of the module comes out providing minified JavaScript for Drupal 7 core.</p>
<p><a href="http://engineeredweb.com/blog/speedy-1-released">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Why It Is Hard To Minify On The Fly]]></title>
    <link href="http://engineeredweb.com/blog/why-hard-minify-on-the-fly"/>
    <updated>2012-04-17T09:55:00-04:00</updated>
    <id>http://engineeredweb.com/blog/why-hard-minify-on-the-fly</id>
    <content type="html"><![CDATA[<p>One of the tips to speed up websites is it <a href="https://developers.google.com/speed/docs/best-practices/payload#MinifyJS">minify the JavaScript</a>. It's simple, effective and <a href="http://www.slideshare.net/mattfarina/front-end-performance-improvements/27">the major players already do it</a> (except <a href="http://drupal.org">Drupal</a>). In the discussions for Drupal 8 and how we can speed up Drupal 7 we've been talking about how we go about providing minified JavaScript files for browsers and there are two camps. One camp wants to ship minified files and the other wants to minify on the fly. While minifying on the fly would be nice it turns out that this is really hard for Drupal and other CMS systems.</p>
<p><a href="http://engineeredweb.com/blog/why-hard-minify-on-the-fly">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[An Hour A Week To Better Documentation]]></title>
    <link href="http://engineeredweb.com/blog/an-hour-better-documentation"/>
    <updated>2012-04-10T07:50:00-04:00</updated>
    <id>http://engineeredweb.com/blog/an-hour-better-documentation</id>
    <content type="html"><![CDATA[<p>If you're like me, a lot of your projects aren't very well documented. If you look over <a href="http://github.com">Github</a> or <a href="http://drupal.org">Drupal.org</a> a significant number of projects are poorly documented. I'm only aware of <a href="http://technosophos.com/">a few people</a> who regularly document their projects well. In an effort to improve the documentation on the projects I maintain (or try to maintain) I've started to schedule an hour per week to just write better documentation.</p>

<p>An important element to note is that this is scheduled time. I've added it to my calendar and scheduled it into my week. To keep this as a useful part of my time I've scheduled it for the second hour of my work week. This gives me time to get through my email and any communication I need to get done (or any slow starts). Then, I start writing documentation before the week gets in the way.</p>

<p>If you'd like to start writing better documentation I invite you to join me in spending an hour a week improving the documentation in our projects.</p>
<p><a href="http://engineeredweb.com/blog/an-hour-better-documentation">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Faster Mobile Sites]]></title>
    <link href="http://engineeredweb.com/blog/faster-mobile-sites-drupalcon-denver"/>
    <updated>2012-04-05T12:00:00-04:00</updated>
    <id>http://engineeredweb.com/blog/faster-mobile-sites-drupalcon-denver</id>
    <content type="html"><![CDATA[<p><strong>87% of the time it takes to load a web page happens in the front end.</strong> <a href="http://www.stevesouders.com/blog/2012/02/10/the-performance-golden-rule/">This it taken from actual measurements of the top 50k websites</a>. When we want to look for ways to speed up our sites we should look to where most of the time is occurring. At <a href="http://denver2012.drupal.org">DrupalCon Denver</a> I presented an introduction to front end performance in the session <a href="http://denver2012.drupal.org/program/sessions/faster-mobile-sites">Faster Mobile Sites</a>. This introduction talked about why front end performance is important, covered some details about what's technically happening, offered some simple solutions to get going, and talked about some useful tools.</p>
<p><a href="http://engineeredweb.com/blog/faster-mobile-sites-drupalcon-denver">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Drupal 8 and Front End Performance]]></title>
    <link href="http://engineeredweb.com/blog/drupal-8-front-end-performance"/>
    <updated>2012-04-03T00:00:00-04:00</updated>
    <id>http://engineeredweb.com/blog/drupal-8-front-end-performance</id>
    <content type="html"><![CDATA[<p>At <a href="http://denver2012.drupal.org">DrupalCon Denver</a> I spoke on Front End Performance improvements we can make to <a href="http://drupal.org">Drupal</a>, why they are important, and provided some information about what's happening technically so we can spot more cases to improve. This presentation was targeted at low barrier to entry changes we can make in Drupal 8 with the short amount of time we have until the feature freeze. If you're interested in front end performance, making Drupal really perform on mobile, or just want to heckle me checkout these slides and video.</p>
<p><a href="http://engineeredweb.com/blog/drupal-8-front-end-performance">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Why Minify JavaScript?]]></title>
    <link href="http://engineeredweb.com/blog/why-minify-javascript"/>
    <updated>2012-03-29T00:00:00-04:00</updated>
    <id>http://engineeredweb.com/blog/why-minify-javascript</id>
    <content type="html"><![CDATA[<p>When I was at <a href="http://denver2012.drupal.org">DrupalCon Denver</a> I suggested that all production JavaScript should be minified. This seemed like something simple that I wouldn't get any push back on. After all, the major JavaScript packages do it and the performance recommendation tools all recommend it. I was wrong. Over the past couple weeks I've received push back from numerous people who've told that me if you use gzip (or deflate) compression there's no need to minify JavaScript. So, here is a case for minifying JavaScript.</p>
<p><a href="http://engineeredweb.com/blog/why-minify-javascript">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Introducting the Speedy Module]]></title>
    <link href="http://engineeredweb.com/blog/speedy-module"/>
    <updated>2012-03-21T00:00:00-04:00</updated>
    <id>http://engineeredweb.com/blog/speedy-module</id>
    <content type="html"><![CDATA[<p>Website front end performance is important. <a href="http://www.stevesouders.com/blog/2012/02/10/the-performance-golden-rule/">Better than 85% of the time it takes for a page to load occurs in the front end</a>. One of the low barrier to entry ways to speed up a site is to make sure the JavaScript sent to browsers is minified. This is considered a standard practice with other common platforms, like Sharepoint and Wordpress, already doing this. The <a href="http://drupal.org/project/speedy">Speedy Module</a> brings minified JavaScript files to <a href="http://drupal.org">Drupal</a> core.</p>
<p><a href="http://engineeredweb.com/blog/speedy-module">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Drupal, HP Cloud, and PHP]]></title>
    <link href="http://engineeredweb.com/blog/drupal-hpcloud-php"/>
    <updated>2012-03-20T00:00:00-04:00</updated>
    <id>http://engineeredweb.com/blog/drupal-hpcloud-php</id>
    <content type="html"><![CDATA[<p>Cloud computing is something a lot of Drupal developers are interested in these days. As someone who works on the cloud, works for a cloud provider, and does a lot of Drupal work I want to see <a href="http://drupal.org">Drupal</a> and <a href="http://hpcloud.com">HP Cloud</a> (my cloud of choice) easily work together. So, we are releasing PHP Bindings and a Drupal module that uses them to bring the HP Cloud to Drupal.</p>
<p><a href="http://engineeredweb.com/blog/drupal-hpcloud-php">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[LossLess Theme Image Optimization with ImageOptim]]></title>
    <link href="http://engineeredweb.com/blog/Losless-Image-Optimization-With-ImageOptim"/>
    <updated>2012-02-13T00:00:00-05:00</updated>
    <id>http://engineeredweb.com/blog/Losless-Image-Optimization-With-ImageOptim</id>
    <content type="html"><![CDATA[<p>I used to think that exporting images from Photoshop for web and devices produced optimized images ready to use in my production sites. Sure, there are optimization techniques you can use for <a href="http://www.smashingmagazine.com/2009/07/15/clever-png-optimization-techniques/">PNGs</a> and <a href="http://www.smashingmagazine.com/2009/07/01/clever-jpeg-optimization-techniques/">JPEGs</a> that I would need to incorporate. But, since Photoshop is considered one of the best imagine editing programs on the market I expected it would do a fantastic job exporting images.</p>

<p>I've since learned there are a number of techniques for producing smaller file sizes without compromising quality that Photoshop doesn't use. For example, 8-bit PNGs with alpha transparency. On the advice of <a href="http://sonspring.com/">Nathan Smith</a> I've started using <a href="http://imageoptim.pornel.net/">ImageOptim</a> to losslessly compress my theme images.</p>
<p><a href="http://engineeredweb.com/blog/Losless-Image-Optimization-With-ImageOptim">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Protocol Relative URLs in Drupal 7]]></title>
    <link href="http://engineeredweb.com/blog/11/12/protocol-relative-urls-drupal-7"/>
    <updated>2011-12-27T00:00:00-05:00</updated>
    <id>http://engineeredweb.com/blog/11/12/protocol-relative-urls-in-drupal-7</id>
    <content type="html"><![CDATA[<p>When I first started tackling <a href="http://engineeredweb.com/blog/11/12/drupal-does-not-respect-https-when-caching" title="Drupal Does Not Respect https:// When Caching">the problem of https and Drupal caching</a> I wanted an interim solution and started by <a href="http://drupal.org/sandbox/mfer/1386376">making the database caching layer smarter</a>. <a href="http://drupal.org/node/1377840#comment-5404064">Neil Drumm had the idea to use protocol-relative (a.k.a, schemeless) URLs</a>. This turns out to be a great idea and thanks to some hooks in Drupal it's something we can implement fairly easily.</p>
<p><a href="http://engineeredweb.com/blog/11/12/protocol-relative-urls-drupal-7">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Drupal Does Not Respect https:// When Caching]]></title>
    <link href="http://engineeredweb.com/blog/11/12/drupal-does-not-respect-https-when-caching"/>
    <updated>2011-12-26T00:00:00-05:00</updated>
    <id>http://engineeredweb.com/blog/11/12/drupal-does-not-respect-https-when-caching</id>
    <content type="html"><![CDATA[<p>One of the problems I recently discovered with the Drupal cache is that it doesn't properly handle https transactions when caching happens. Let's take a look at understanding the problem, an interim solution for the database cache, and finding a long term solution.</p>

<h2>The Problem</h2>


<p><img src="http://engineeredweb.com/media/images/page-cache-https-issue.png" width="585" height="565" alt="page-cache-https-issue.png" /></p>

<p>The page cache properly respects https because it uses a full url including the protocol when generating a cache id. But, Drupal uses multiple layers of caching with the html in a page. For example, the content of blocks can be cached. What if the html for a block has absolute URLs pointing back to the site and those are generated on the http version of the site. Then this is cached. Then this cache is used to create the https version of the page. Then those cached absolute URLs are not using https.</p>

<h3>Media Module, Where I Found The Problem</h3>


<p>The example that caused me to understand this problem was the media module. With the media module you can embed images and video into a text area (like the body of an article). Media tags are converted to html by the filter system and the results are cached. Images, for example, use absolute URLs (this is part of core and is a good thing for some use cases). If the cache for this text was generated on the http version of the site the path to the image on the https version of the page will use http as the protocol.</p>

<p>This opens up all kids of possible issues. Just imagine someone in a coffee shop thinking they are on https only to have cookies sent back to the server for that image in plain text. Or maybe you have a better imagination than me and can think of something more sinister.</p>

<h3>Nested Caching</h3>


<p>The issues is nested caching of html and how many of the nested caches don't respect the protocol like the page cache does. This can apply to any html that's cached across any modules.</p>

<h2>Fixing Database Caching In The Short Term</h2>


<p>To work around this problem I've started a <a href="http://drupal.org/sandbox/mfer/1386376">database caching layer that works around this problem by respecting https for most caches</a>. I don't really like this solution and there are some definite hacks in how it works. The real solution should be to have the code saving and retrieving from the html caches be smart enough to include the protocol in the caches. Unfortunately, a cache backend can't fix the places the cache is used.</p>

<h2>A Long Term Solution</h2>


<p>An <a href="http://drupal.org/node/1377840">issue for a long term solution</a> is already open. If you have any experience in this area, it impacts your sites, or you want to help out please head over there so we can fix this moving forward.</p>
<p><a href="http://engineeredweb.com/blog/11/12/drupal-does-not-respect-https-when-caching">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[DrupalCamp Michigan Registration Re-Opened]]></title>
    <link href="http://engineeredweb.com/blog/11/10/drupalcamp-michigan-registration-re-opened"/>
    <updated>2011-10-17T00:00:00-04:00</updated>
    <id>http://engineeredweb.com/blog/11/10/drupalcamp-michigan-registration-re-opened</id>
    <content type="html"><![CDATA[<p><img src="http://engineeredweb.com/media/images/logos/DrupalCampMI-2011.png" width="144" height="144" alt="DrupalCampMI-2011.png" align="left" class="float-left" />When we first started planning <a href="http://drupalcampmi.org">DrupalCamp Michigan</a> we didn't have high expectations for turnout. Southeast Michigan, where the camp is being held, is not known for a large or active Drupal community. When we sold out less than 3 weeks after we had the idea for the camp it was a very present surprise. But, we knew there were more people who wanted to come and an opportunity to reach more people. So, we've added more space and re-opened registration.</p>

<p>Special thanks to <a href="http://bluedrop.me/">Jason Savino</a> for jumping all over this, coordinating with others in the local community (especially <a href="http://www.commerceguys.com/">Mike O'Connor from the Commerce Guys</a> who was also working on this), and making the extra space happen quickly.</p>
<p><a href="http://engineeredweb.com/blog/11/10/drupalcamp-michigan-registration-re-opened">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[The First DrupalCamp Michigan]]></title>
    <link href="http://engineeredweb.com/blog/11/10/first-drupalcamp-michigan"/>
    <updated>2011-10-03T00:00:00-04:00</updated>
    <id>http://engineeredweb.com/blog/11/10/the-first-drupalcamp-michigan</id>
    <content type="html"><![CDATA[<p><a href="http://drupalcampmi.org" title="DrupalCamp Michigan"><img src="http://engineeredweb.com/media/images/logos/DrupalCampMI-2011.png" width="144" height="144" alt="DrupalCampMI-2011.png" class="float-left" align="left" /></a><strong>This December 3rd will be the very first <a href="http://drupalcampmi.org/">DrupalCamp Michigan</a>.</strong> Our initial go at a DrupalCamp will be a one day event at the <a href="http://g.co/maps/uzajh">Crowne Plaza in Novi</a>. The event is being sponsored and attended by the local Drupal shops of <a href="http://www.commerceguys.com">Commerce Guys</a>, <a href="http://mustardseedmedia.com">Mustardseed Media</a>, <a href="http://switchbackcms.com/">Switchback</a>, and <a href="http://www.commercialprogression.com">Commercial Progression</a>.</p>

<p>If you're interested in attending head on over to http://drupalcampmi.org for more details and to register. Space is limited.</p>
<p><a href="http://engineeredweb.com/blog/11/10/first-drupalcamp-michigan">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[The Drupal Community and Front End Performance]]></title>
    <link href="http://engineeredweb.com/blog/11/9/drupal-community-and-front-end-performance"/>
    <updated>2011-09-20T00:00:00-04:00</updated>
    <id>http://engineeredweb.com/blog/11/9/the-drupal-community-and-front-end-performance</id>
    <content type="html"><![CDATA[<p><strong><a href="http://drupal.org">Drupal</a> has a presence problem when it comes to front end performance. Drupal has for the most part ignored front end performance.</strong> According to a <a href="http://www.readwriteweb.com/hack/2011/06/mobile-page-response.php">study by Strangeloop</a>, 97% of the time it takes a mobile page to render is in the front end. For desktop browser the front end makes up 85% of the time. These numbers may feel high. But, when pages take 500ms to render in Drupal but 6 seconds to display in an end users browser you can see where this comes from.</p>

<p>The presence problem for Drupal can be seen in several places:</p>

<ol>
 <li>A the past few DrupalCons how many sessions have touched on front end performance? I can only recall one of them while there have been many covering memcache, apc, and other server side technologies.</li>
 <li>Take a look at the documentation pages on <a href="http://drupal.org/node/79237">profiling</a> <a href="http://drupal.org/node/282862">Drupal</a>. Or, search for documentation pages on performance. You'll find discussions about apache benchmark, learn about varnish, etc. You won't learn about font end performance.</li>
 <li>Drupal doesn't provide minified JavaScript. For production environments this is considered a standard practice.</li>
 <li>The <a href="http://groups.drupal.org/node/166704">Drupal 8 development "gates" RFC</a> gives 1 of 6 performance items to font end performance. The other 5 are tips/gates in detail for back end issues we've commonly run into. The front end one is a basic one liner.</li>
</ol>


<p>Front end performance is a big deal. This is more so true as we enter into the dominance of mobile where mobile devices are low powered and on high latency networks.</p>

<h2>What We Can Do About It</h2>


<p>Pointing out problems is no good without solutions. The problem is in the amount of face time front end performance gets. So, lets get it some face time.</p>

<ul>
 <li>At DrupalCamps let's start presenting on it.</li>
 <li>Drupal companies could benefit from having someone knowledge in house. Come up with ways to add it to your expertise. Maybe hold a book club and discuss <a href="http://www.amazon.com/Steve-Souders/e/B001I9TVJS/ref=ntt_athr_dp_pel_1">a Steve Souders book</a>.</li>
 <li>When we learn about useful tools like <a href="http://imageoptim.pornel.net/">ImageOptim</a> or <a href="http://www.spritecow.com/">Sprite Cow</a> lets share them.</li>
 <li>If you see a contrib module serving JavaScript up that has not been minified file a patch. You can <a href="http://marijnhaverbeke.nl/uglifyjs">use UglifyJS easily through the web</a>. UglifyJS is what jQuery uses.</li>
</ul>


<p>Front end performance is a big deal. It's the largest part of the performance equation an end user experiences. Companies have done studies showing the financial and usage impact of end user performance. Let's elevate front end performance to the place it needs to be in the Drupal community.</p>
<p><a href="http://engineeredweb.com/blog/11/9/drupal-community-and-front-end-performance">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[SplFixedArray, An Underutilized PHP Gem]]></title>
    <link href="http://engineeredweb.com/blog/11/9/splfixedarray-underutilized-php-gem"/>
    <updated>2011-09-08T00:00:00-04:00</updated>
    <id>http://engineeredweb.com/blog/11/9/splfixedarray-an-underutilized-php-gem</id>
    <content type="html"><![CDATA[<p>Arrays in PHP are not arrays per the typical <a href="http://en.wikipedia.org/wiki/Array_data_type" title="Wikipedia: Array data type">array data type</a>. Instead, as Matt Butcher recently pointed out <a href="http://technosophos.com/content/php-arrays-are-not-arrays" title="PHP Arrays are NOT Arrays">arrays in PHP are similar to hashes in other languages</a>. This can be a very important point to know when tracking down bugs in code and to programmers coming to PHP from other languages. But, what if we wanted something like a traditional array data type? Maybe something that preserved numeric order. Enter <a href="splfixedarray" title="PHP: SplFixedArray">SplFixedArray</a>.</p>
<p><a href="http://engineeredweb.com/blog/11/9/splfixedarray-underutilized-php-gem">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[JavaScript Theme Functions in Drupal]]></title>
    <link href="http://engineeredweb.com/blog/11/5/javascript-theme-functions-drupal"/>
    <updated>2011-05-16T00:00:00-04:00</updated>
    <id>http://engineeredweb.com/blog/11/5/javascript-theme-functions-in-drupal</id>
    <content type="html"><![CDATA[<p><a href="http://drupal.org">Drupal</a> has an extensive theming system which includes theme functions that can be overridden and an extensible template system. There is an expectation that all markup go through the theme system and it is considered a bug when that doesn't happen. Most of the talk surrounding this system focuses on the server side system and what we can do in PHP. But, that's not all there is to the theme system. <strong>Drupal provides a theme system for JavaScript as well.</strong> One with callbacks that can be overridden by themes, just like on the PHP side.</p>

<h2>Theme Functions</h2>


<p>The central function to the theme system is <code lang="javascript">Drupal.theme()</code>. It is the JavaScript counterpart to <a href="http://api.drupal.org/theme"><code lang="php">theme()</code></a> and works in a similar manner to what <code lang="php">theme()</code> did in Drupal 6.</p>

<p>The first step is to define a JavaScript theme function within a modules JavaScript file, then <code lang="javascript">Drupal.theme()</code> can use it. To define a theme function simply create a new function in the Drupal theme prototype namespace like:
<div class="highlight"><pre><code class="javascript"><span class="nx">Dupal</span><span class="p">.</span><span class="nx">theme</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">displayName</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">url</span><span class="p">)</span> <span class="p">{</span>
  <span class="k">return</span> <span class="s1">&#39;&lt;a href=&quot;&#39;</span> <span class="o">+</span> <span class="nx">url</span> <span class="o">+</span> <span class="s1">&#39;&quot;&gt;&#39;</span> <span class="o">+</span> <span class="nx">name</span> <span class="o">+</span> <span class="s1">&#39;&lt;/a&gt;&#39;</span><span class="p">;</span>
<span class="p">}</span>
</code></pre>
</div>
</p>

<p>Once this is done the function can be used like:
<div class="highlight"><pre><code class="javascript"><span class="kd">var</span> <span class="nx">name</span> <span class="o">=</span> <span class="s2">&quot;John Doe&quot;</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">url</span> <span class="o">=</span> <span class="s2">&quot;http://example.com&quot;</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">display</span> <span class="o">=</span> <span class="nx">Drupal</span><span class="p">.</span><span class="nx">theme</span><span class="p">(</span><span class="s1">&#39;displayName&#39;</span><span class="p">,</span> <span class="nx">name</span><span class="p">,</span> <span class="nx">url</span><span class="p">);</span>
</code></pre>
</div>
</p>

<p>Just like the Drupal 6 <code lang="php">theme()</code> function usage, the arguments minus the first one are passed to the theme function itself. The first argument is the name of the function in the <code lang="javascript">Drupal.theme.prototype</code> namespace.</p>

<h2>Overriding Theme Functions in Themes</h2>


<p>Not only does this system allow us to reuse theme functions as templates, it provides a mechanism for themes to override these theme functions. For example, a module defines a theme function like the one above and uses it. But, a theme wants to change the markup. The theme can define an override function like:
<div class="highlight"><pre><code class="javascript"><span class="nx">Dupal</span><span class="p">.</span><span class="nx">theme</span><span class="p">.</span><span class="nx">displayName</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">url</span><span class="p">)</span> <span class="p">{</span>
  <span class="k">return</span> <span class="s1">&#39;&lt;a href=&quot;&#39;</span> <span class="o">+</span> <span class="nx">url</span> <span class="o">+</span> <span class="s1">&#39;&quot;&gt;&lt;em&gt;&#39;</span> <span class="o">+</span> <span class="nx">name</span> <span class="o">+</span> <span class="s1">&#39;&lt;/em&gt;&lt;/a&gt;&#39;</span><span class="p">;</span>
<span class="p">}</span>
</code></pre>
</div>
</p>

<p>This theme function has a slightly different name. <code lang="javascript">Drupal.theme</code> is the namespace instead of <code lang="javascript">Drupal.theme.prototype</code>. The function name is the same as is the function argument signature.</p>

<p>When <code lang="javascript">Drupal.theme()</code> sees this override function it uses it instead of the one defined by the module.</p>

<h2>What Should Go Through Theme Functions?</h2>


<p>The obvious answer is that all markup should go through theme functions. But, there is more to front end presentation than CSS and markup. For example, animations. It's not uncommon for JavaScript to cause something to display. What if a theme wanted that to slide in rather than just show up in the page? This is not something you can accomplish via markup and CSS changes.</p>

<p>So, instead of thinking of these theme functions as a place for markup consider putting from end presentation in them. All of it. Drupal JavaScript theme functions are something we need to use more. It is the system we currently have and one we should embrace.</p>

<p>For more information on the topic please see the <a href="http://drupal.org/node/171213">Drupal.org handbook page</a>.</p>
<p><a href="http://engineeredweb.com/blog/11/5/javascript-theme-functions-drupal">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Translatable Strings In Drupal JavaScript]]></title>
    <link href="http://engineeredweb.com/blog/11/5/translatable-strings-drupal-javascript"/>
    <updated>2011-05-01T00:00:00-04:00</updated>
    <id>http://engineeredweb.com/blog/11/5/translatable-strings-in-drupal-javascript</id>
    <content type="html"><![CDATA[<p><a href="http://drupal.org" title="Drupal - Content Management Platform">Drupal</a> is known for being highly translatable. The localization team has done a fantastic job building out tools to make Drupal translatable and it's rare to find a module that doesn't properly wrap its strings in the <a href="http://api.drupal.org/t"><code lang=""php">t()</code></a> function or the lesser known <a href="http://api.drupal.org/format_plural"><code lang=""php">format_plural()</code></a> function. While the Drupal community is doing fairly well on the PHP side, many people don't know there is a translation system for Drupal JavaScript as well through the use of the <code lang="javascript">Drupal.t()</code> and <code lang="javascript">Drupal.formatPlural()</code> functions.</p>
<p><a href="http://engineeredweb.com/blog/11/5/translatable-strings-drupal-javascript">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Build your JavaScript With jQuery 1.5.2 in Drupal 7]]></title>
    <link href="http://engineeredweb.com/blog/11/4/build-your-javascript-jquery-152-drupal-7"/>
    <updated>2011-04-05T00:00:00-04:00</updated>
    <id>http://engineeredweb.com/blog/11/4/build-your-javascript-with-jquery-1-5-2-in-drupal-7</id>
    <content type="html"><![CDATA[<p>Shortly after <a href="http://drupal.org">Drupal 7</a> launched the version of <a href="http://jquery.com">jQuery</a> shipped with Drupal became outdated. Drupal 7 ships with jQuery 1.4.4 but the jQuery community has shipped jQuery 1.5.2. When we are developing the JavaScript in our shinny new Drupal 7 we are already using an outdated version of jQuery. But, there is a solution. The<a href="http://drupal.org/project/jquery_update"> jQuery Update</a> module provides an update for core to jQuery 1.5.2 and jQuery UI 1.8.11.</p>
<p><a href="http://engineeredweb.com/blog/11/4/build-your-javascript-jquery-152-drupal-7">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Drupal 8 JavaScript Excellence Roadmap]]></title>
    <link href="http://engineeredweb.com/blog/11/3/drupal-8-javascript-excellence-roadmap"/>
    <updated>2011-03-17T00:00:00-04:00</updated>
    <id>http://engineeredweb.com/blog/11/3/drupal-8-javascript-excellence-roadmap</id>
    <content type="html"><![CDATA[<p>Over the past several months there has been a bit of talk attempting to answer the question, how can we make our JavaScript something we can be proud of and others want to use. Through the conversations, which included a Birds of a Feature session at DrupalCon Chicago, we <em>(a number of people in the community)</em> have come up with eight points of attack to make the JavaScript in Drupal 8 awesome. These aren't everything we hope to accomplish but are an important piece of the puzzle.</p>
<p><a href="http://engineeredweb.com/blog/11/3/drupal-8-javascript-excellence-roadmap">Continue Reading &raquo;</a></p>]]></content>
  </entry>
  
</feed>
