<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>Straylight Run &#187; front-end</title> <atom:link href="http://blog.straylightrun.net/tag/front-end/feed/" rel="self" type="application/rss+xml" /><link>http://blog.straylightrun.net</link> <description>Software, Technology, PHP</description> <lastBuildDate>Mon, 07 Nov 2011 19:26:59 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Making Blueprint CSS Grid Mobile-Friendly</title><link>http://blog.straylightrun.net/2011/11/07/making-blueprint-css-grid-mobile-friendly/</link> <comments>http://blog.straylightrun.net/2011/11/07/making-blueprint-css-grid-mobile-friendly/#comments</comments> <pubDate>Mon, 07 Nov 2011 19:19:40 +0000</pubDate> <dc:creator>gerard</dc:creator> <category><![CDATA[Coding]]></category> <category><![CDATA[css]]></category> <category><![CDATA[design]]></category> <category><![CDATA[front-end]]></category> <category><![CDATA[layout]]></category> <guid
isPermaLink="false">http://blog.straylightrun.net/2011/11/07/making-blueprint-css-grid-mobile-friendly/</guid> <description><![CDATA[I had an existing site I created using Blueprint CSS a while ago. I wanted to make it mobile-friendly. There are responsive CSS grid frameworks out there now, but I didn’t feel like replacing Blueprint, and I figured all I had to do was, using media queries, make every column span a fixed width. That [...]]]></description> <content:encoded><![CDATA[<p>I had an existing site I created using <a
href="http://blueprintcss.org/">Blueprint CSS</a> a while ago. I wanted to make it mobile-friendly. There are <a
href="http://framelessgrid.com/">responsive CSS</a> <a
href="http://getskeleton.com/">grid frameworks</a> out there now, but I didn’t feel like replacing Blueprint, and I figured all I had to do was, using media queries, make every column span a fixed width. That was mostly correct. In the end, I used 100% widths, plus a few other alterations.&#160; Here is how I ended up doing it.</p><p>Normally, you will link to your Blueprint <code>screen.css</code> file like so:</p><div
class="wp_syntax"><div
class="code"><pre class="html" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/css/screen.css&quot; media=&quot;screen, projection&quot; /&gt;</pre></div></div><p>The following lines tell the browser to link first to a mobile-friendly CSS file. Then, if and when the width is <code>600px</code>, link to the normal, desktop CSS file. The idea is that bandwidth is scarcer on mobile, so we don&#8217;t mind downloading two files on a desktop machine if we have to.</p><div
class="wp_syntax"><div
class="code"><pre class="html" style="font-family:monospace;">&lt;!-- For mobile displays --&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/css/mobile.css&quot; media=&quot;screen, projection&quot; /&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/css/print.css&quot; media=&quot;print&quot; /&gt;
&nbsp;
&lt;!-- For desktop displays --&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;/css/screen.css&quot; media=&quot;only screen and (min-width: 600px)&quot; /&gt;</pre></div></div><p>To create my <code>mobile.css</code>, I copied <code>screen.css</code>, and made the following changes.</p><ol><li>Change table elements padding to <code>2px</code><p></p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;">th<span style="color: #00AA00;">,</span> td<span style="color: #00AA00;">,</span> caption <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div></li><li>Change <code>input</code> text fields to 67% width.<p></p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;">input.<span style="color: #993333;">text</span><span style="color: #00AA00;">,</span> input<span style="color: #6666ff;">.title</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">67%</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div></li><li>Change <code>textarea</code> inputs to 80% width, and reduce <code>height</code> to <code>150px</code>.<p></p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;">textarea <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">80%</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">150px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div></li><li>Change the overall <code>container</code> to 100% width.<p></p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.container</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div></li><li>Change all <code>span</code> grid classes to 100% width.<p></p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.span-1</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
...
<span style="color: #6666ff;">.span-24</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div></li><li>For some reason, I ended up deleting all <code>input.span</code> and <code>textarea.span</code> classes, though I&#8217;m not sure why now.</li><li>Change all <code>append</code> grid classes to <code>0px</code> right padding.<p></p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.append-1</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">padding-right</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
...
<span style="color: #6666ff;">.append-24</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">padding-right</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div></li><li>Change all <code>prepend</code> grid classes to <code>0px</code> left padding.<p></p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.prepend-1</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
...
<span style="color: #6666ff;">.prepend-24</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div></li><li>Change all <code>pull</code> grid classes to <code>0px</code> left margin.<p></p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.pull-1</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
...
<span style="color: #6666ff;">.pull-24</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div></li><li>Change all <code>push</code> grid classes to <code>0px</code> margin.<p></p><div
class="wp_syntax"><div
class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.push-1</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
...
<span style="color: #6666ff;">.push-24</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div></li></ol><p>Not pretty, but it seems to work well.&#160; Happy CSS!</p> ]]></content:encoded> <wfw:commentRss>http://blog.straylightrun.net/2011/11/07/making-blueprint-css-grid-mobile-friendly/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Automate Your Front-End Optimization Using Phing</title><link>http://blog.straylightrun.net/2010/05/10/automate-your-front-end-optimization-using-phing/</link> <comments>http://blog.straylightrun.net/2010/05/10/automate-your-front-end-optimization-using-phing/#comments</comments> <pubDate>Mon, 10 May 2010 23:56:31 +0000</pubDate> <dc:creator>gerard</dc:creator> <category><![CDATA[Process]]></category> <category><![CDATA[build server]]></category> <category><![CDATA[continuous integration]]></category> <category><![CDATA[front-end]]></category> <category><![CDATA[github]]></category> <category><![CDATA[phing]]></category> <category><![CDATA[yahoo]]></category> <category><![CDATA[yslow]]></category> <category><![CDATA[yui]]></category> <guid
isPermaLink="false">http://blog.straylightrun.net/2010/05/10/automate-your-front-end-optimization-using-phing/</guid> <description><![CDATA[Well, it only took me 18 months, but I finally got around to cleaning up and publishing the Phing filters we use to automatically transform a static site into one that implements many of Yahoo’s Exceptional Performance Rules.&#160; These filters, together with the Apache configurations in the README, implement the process outlined in this talk [...]]]></description> <content:encoded><![CDATA[<p>Well, it <a
href="http://blog.straylightrun.net/2008/11/16/slides-from-phpworks-2008-part-2/">only took me 18 months</a>, but I finally got around to cleaning up and publishing the Phing filters we use to <a
href="http://github.com/gsychay/Phing-Things">automatically transform a static site</a> into one that implements many of <a
href="http://developer.yahoo.com/performance/">Yahoo’s Exceptional Performance Rules</a>.&#160; These filters, together with the Apache configurations in the <a
href="http://github.com/gsychay/Phing-Things/blob/master/README.md">README</a>, implement the process outlined in this <a
href="http://www.slideshare.net/gerrys0/front-end-website-optimization-presentation">talk from php|works 2008</a>:</p><p>To see it in action, first create an <code>VirtualHost</code> pointing to the <code>mysite</code> directory in the project as the web root.&#160; Then run:</p><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">% phing optimize</pre></div></div><p>which creates a parallel site in a <code>build</code> directory.&#160; Point your <code>VirtualHost</code> to the new <code>build</code> directory to see the same site with the performance transformations.</p><p>You could run this <a
href="http://phing.info">Phing</a> task in a <a
href="http://martinfowler.com/articles/continuousIntegration.html">continuous integration</a> process as part of deployment.&#160; You could run it at production deployment time, but it’s probably a good idea to run it at staging time in case it flubs on some CSS or HTML syntax that it is not expecting.</p><p>Note that there are other miscellaneous Phing tasks in that <a
href="http://github.com/gsychay/Phing-Things">github project</a>.&#160; I threw these in there in case they could be of use to other Phing users.</p> ]]></content:encoded> <wfw:commentRss>http://blog.straylightrun.net/2010/05/10/automate-your-front-end-optimization-using-phing/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Serving Javascript and CSS</title><link>http://blog.straylightrun.net/2009/01/23/serving-javascript-and-css/</link> <comments>http://blog.straylightrun.net/2009/01/23/serving-javascript-and-css/#comments</comments> <pubDate>Fri, 23 Jan 2009 19:16:22 +0000</pubDate> <dc:creator>gerard</dc:creator> <category><![CDATA[Coding]]></category> <category><![CDATA[Performance]]></category> <category><![CDATA[css]]></category> <category><![CDATA[front-end]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[optimization]]></category> <guid
isPermaLink="false">http://blog.straylightrun.net/2009/01/23/serving-javascript-and-css/</guid> <description><![CDATA[Editor&#8217;s note: This post formed the basis of the Front-End Optimization talk I&#8217;ve given in the past. You&#8217;ve programmed websites for years, know the ins &#38; outs of PHP, MySQL, why are Javascript and CSS files such a big deal? You put them in a directory, and link to them from your pages. Done. Right? [...]]]></description> <content:encoded><![CDATA[</p><p><em>Editor&#8217;s note: This post formed the basis of the <a
href="http://blog.straylightrun.net/2008/11/08/slides-from-phpworks-2008/">Front-End Optimization talk</a> I&#8217;ve given in the past.</em></p><p>You&#8217;ve programmed websites for years, know the ins &amp; outs of PHP, MySQL, why are Javascript and CSS files such a big deal? You put them in a directory, and link to them from your pages. Done. Right?</p><p>Not if you want maximum performance.</p><p>According to the <a
href="http://yuiblog.com/blog/2006/11/28/performance-research-part-1/">Yahoo Exception Performance</a> team:</p><blockquote><p>&#8230;Only 10% of the time is spent here for the browser to request the HTML page, and for apache to stitch together the HTML and return the response back to the browser. The other 90% of the time is spent fetching other components in the page including images, scripts and stylesheets.</p></blockquote><p>So static content <em>is </em>very important. The same Yahoo people provide us with a comprehensive list of <a
href="http://developer.yahoo.com/performance/rules.html">Best (Front-end) Practices for Speeding Up Your Website</a>.&#160; IMO, some of the rules are more important than others, and some are more easily achieved.&#160; Leaving aside hardware solutions (static server, CDN, etc.) for now, let&#8217;s look at six of the rules:</p><ol><li><a
href="http://developer.yahoo.com/performance/rules.html#num_http">Rule 1: Make Fewer HTTP Requests</a>, or combine files. The less downloads the better. Simple file concatenation would do. Our goal is at most one Javascript and one CSS file per page.</li><li><a
href="http://developer.yahoo.com/performance/rules.html#expires">Rule 3: Add an Expires Header</a>, or every static file must accompany a time-stamp so we can take advantage of the HTTP Expires: header. A time-stamp in the GET parameters might work, but some say that some CDN&#8217;s and browser/version/platform combinations will not request a new file if the query string changes. A better solution would be to put the time-stamp in the filename somewhere.</li><li><a
href="http://developer.yahoo.com/performance/rules.html#gzip">Rule 4: Gzip Components</a>. This is easily achieved by enabling <code>mod_deflate </code>in Apache.</li><li><a
href="http://developer.yahoo.com/performance/rules.html#dns_lookups">Rule 9: Reduce DNS Lookups</a>. Okay, the real value in this rule is introducing parallel downloads by using at least two but no more than four host names. This is better explained <a
href="http://yuiblog.com/blog/2007/04/11/performance-research-part-4/">here</a>. <a
href="http://developer.yahoo.com/performance/rules.html#dns_lookups"> <br
/></a></li><li><a
href="http://developer.yahoo.com/performance/rules.html#minify">Rule 10: Minify JavaScript</a>, or at the least strip out all whitespace and comments. There are more sophisticated compressors out there that replace your actual variables with shorter symbols, but the chances of introducing bugs is higher.</li><li><a
href="http://developer.yahoo.com/performance/rules.html#js_dupes">Rule 12: Remove Duplicate Scripts</a>, which as they say is more common than you think.</li></ol><p>Rule 3 is a matter of configuring Apache. How to achieve the other five?</p><p>As I see it, there are three broad ways to achieve them.</p><ol><li>Handle every request in real-time.&#160; This means using a PHP file to serve the files (e.g. <code>&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;custom_handler.php?file1.css,file2.css&quot; /&gt;</code> or something like that).&#160; It can also mean using <code>mod_rewrite</code> to direct incoming requests for CSS and Javascript to go to a PHP script. Either way, there is processing on <em>every page load. </em>Caching the end-product helps. Still, there must be a better way.</li><li>Use a template or view plugin.&#160; If you are using a templating system to dynamically generate your HTML, you can use some sort of plugin or function to read in a list of static files, check their last-modified times, and if changed build a combined, minified, time-stamped output file to serve up.&#160; This is better than method #1 because by the time the page is built, there is a static file that is simply served to the browser.&#160; Still, there must be a better way.</li><li>The best way is to do it offline.&#160; This means a job that checks static files to see if they&#8217;ve been modified.&#160; If so, it processes the files and builds the output file that is directly served to the browser.&#160; This job could be run in cron, or run manually by developers, but the best way is to make it a part of the build server.</li></ol><p>Don&#8217;t have a build server?&#160; That&#8217;s a whole other topic.</p> ]]></content:encoded> <wfw:commentRss>http://blog.straylightrun.net/2009/01/23/serving-javascript-and-css/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
