<?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>Falise.com &#187; gzip</title>
	<atom:link href="http://www.falise.com/tag/gzip/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.falise.com</link>
	<description>Falise.com, een klein webbureau uit Utrecht. Gespecialiseerd in Wordpress, CakePhp, Flash, jQuery, XHTML, CSS, PHP</description>
	<lastBuildDate>Fri, 24 May 2013 12:24:06 +0000</lastBuildDate>
	<language>nl-NL</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Getting good grades with YSlow &#8211; Part 1: Combining javascript and CSS files</title>
		<link>http://www.falise.com/blog/wordpress-code/good-yslow-grades-javascript-css/</link>
		<comments>http://www.falise.com/blog/wordpress-code/good-yslow-grades-javascript-css/#comments</comments>
		<pubDate>Sun, 18 Sep 2011 12:37:51 +0000</pubDate>
		<dc:creator>Sander</dc:creator>
				<category><![CDATA[Wordpress code]]></category>
		<category><![CDATA[combine]]></category>
		<category><![CDATA[compress]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[yslow]]></category>

		<guid isPermaLink="false">http://www.falise.com/?p=240</guid>
		<description><![CDATA[<p>Having a website that loads as fast as possible isn&#8217;t just good news for your visitors, it can also improve your page ranking on search engines. YSlow is a tool from Yahoo that let&#8217;s you measure just how fast your ...</p><p><a href="http://www.falise.com/blog/wordpress-code/good-yslow-grades-javascript-css/">Getting good grades with YSlow &#8211; Part 1: Combining javascript and CSS files</a></p>]]></description>
				<content:encoded><![CDATA[<p>Having a website that loads as fast as possible isn&#8217;t just good news for your visitors, it can also improve your page ranking on search engines. <a href="http://developer.yahoo.com/yslow/" target="_blank">YSlow</a> is a tool from Yahoo that let&#8217;s you measure just how fast your website is loading and what might be causing delays. Once installed and activated you can begin measuring your page loading speed. How well is your website performing? Ours was a C (scoring 72) before the optimizations suggested below, it&#8217;s an A (scoring 92) now. Read on for some <a title="Wordpress" class="aal" target=""  href="/tag/wordpress">WordPress</a> specific tips on how you can optimize your website.</p>
<p><span id="more-240"></span></p>
<p>Loading multiple small files is slower than loading one big file; each connection takes time to set up so lets minimize the number of connections your website makes. Ideally you only need two connections; one for all your javascript files and one for all your CSS files. There are a variety of plugins available to do this but since we like to code we have devised own method. Simply put, we create a php file that includes the files we need. On top of that it also applies gzip compression (making the file a lot smaller) and adds expiration headers (so your browser can cache the files and only needs to load them once). Get ready for some code!</p>
<p>We&#8217;re assuming you put all your CSS files in a directory named <em>css</em> and put all your javascripts files in a directory named <em>js</em>, these directories reside in your theme directory. In both directories we created files named index.php, this saves a few bytes when include the files in the head of our html document.</p>
<h2>Creating css/index.php</h2>
<p>Create a file named index.php in your css directory and fill it with the code below:</p>
<pre>&lt;?php
  ob_start ("ob_gzhandler"); // gzip compression
  header("Content-type: text/css; charset: UTF-8"); // mime-type
  header("Cache-Control: must-revalidate");
  header("Expires: " . gmdate("D, d M Y H:i:s", time() + 604800) . " GMT"); // near future expires header

  $dir = ''; // root dir for your css files

  // array of css files and their media type
  $css = array(
    'all' =&gt; array(
      'reset.css'
    ),
    'handheld' =&gt; array(
      'handheld.css'
    ),
    'screen' =&gt; array(
      'screen.css'
    )
  );

  // include all css files and wrap them in <a href="http://twitter.com/media" class="tweet-username">@media</a> 
  foreach($css as $media =&gt; $urls)
  {
    echo "<a href="http://twitter.com/media" class="tweet-username">@media</a> $media {\n\n";
    foreach($urls as $url)
    {
      if (!empty($url)) include($dir . $url);
    }
    echo "}\n\n";
  }
?&gt;</pre>
<p>Find all references to css files in your theme and add the css file names to the $css array. Each media type has it&#8217;s own key, so put them in the right place! When your done, delete all the old css references in your theme and replace them with the following line of code:</p>
<pre>&lt;link rel="stylesheet" type="text/css" href="<!--?php echo get_bloginfo('theme_dir'); ?-->/css/" /&gt;</pre>
<h2>Creating js/index.php</h2>
<p>Lets do the same for javascript files, create a file named index.php in your js directory and fill it with the code below:</p>
<pre>&lt;?php
  ob_start("ob_gzhandler"); // gzip compression
  header("content-type: application/x-javascript"); // mime-type
  header("Cache-Control: must-revalidate");
  header("Expires: " . gmdate("D, d M Y H:i:s", time() + 604800) . " GMT"); // near future expires header

  $dir = ''; // root dir for your js files

  // array of scripts files
  $scripts = array(
    '<a title="jquery" class="aal" target=""  href="/tag/jquery">jquery</a>-1.6.2.min.js',
    'script.js'
  );

  foreach($scripts as $script)
  {
    include($script);
  }
?&gt;</pre>
<p>Find all references to javascript files in your theme and add the file names to the $scripts array. When your done, delete all the old javascript references in your theme and replace them with the following line of code:</p>
<pre>&lt;script src="<!--?php echo get_bloginfo('theme_dir'); ?-->/js/" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt;</pre>
<p>All done! Now check your website again in YSlow and see the differences. Our CSS file was 21KB without compression and 5.8KB with compression. Our javascript file went from 126KB to 42.5KB. Did you notice you don&#8217;t actually need to have &#8216;index.php&#8217; in your script or link tags? Saves a few bytes as well!</p>
<p><a href="http://www.falise.com/blog/wordpress-code/good-yslow-grades-javascript-css/">Getting good grades with YSlow &#8211; Part 1: Combining javascript and CSS files</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.falise.com/blog/wordpress-code/good-yslow-grades-javascript-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Database Caching 3/18 queries in 0.023 seconds using disk
Object Caching 479/495 objects using disk

 Served from: www.falise.com @ 2013-05-25 03:39:44 by W3 Total Cache -->