<?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>gj |</title>
	<atom:link href="https://blog.gaiterjones.com/category/magento/pagespeed/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.gaiterjones.com/category/magento/pagespeed/</link>
	<description>gaiterjones</description>
	<lastBuildDate>Fri, 28 Aug 2015 10:46:36 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.3</generator>
	<item>
		<title>Magento Google Pagespeed js,css,htmlminify Optimisation</title>
		<link>https://blog.gaiterjones.com/magento-google-pagespeed-jscsshtmlminify-optimisation/</link>
					<comments>https://blog.gaiterjones.com/magento-google-pagespeed-jscsshtmlminify-optimisation/#comments</comments>
		
		<dc:creator><![CDATA[PAJ]]></dc:creator>
		<pubDate>Fri, 28 Aug 2015 10:24:32 +0000</pubDate>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[Pagespeed]]></category>
		<guid isPermaLink="false">http://blog.gaiterjones.com/?p=1407</guid>

					<description><![CDATA[Google PageSpeed is a family of tools by Google Inc, designed to help a website’s performance optimisations. Page speed is important for Magento customers, Google search and for SEO. The...<a class="more-link" href="https://blog.gaiterjones.com/magento-google-pagespeed-jscsshtmlminify-optimisation/" title="Continue reading">Continue reading</a>]]></description>
										<content:encoded><![CDATA[<p>Google PageSpeed is a family of tools by Google Inc, designed to help a website’s performance optimisations. Page speed is important for Magento customers, Google search and for SEO. The question is, is it possible to achieve a 100/100 rating with the Google Pagespeed insight tool?</p>
<figure id="attachment_1409" aria-describedby="caption-attachment-1409" style="width: 336px" class="wp-caption aligncenter"><img decoding="async" class="wp-image-1409 size-full" src="https://blog.gaiterjones.com/wp-content/uploads/2015/08/pagespeed-100-100.png" alt="pagespeed-100-100" width="336" height="98" /><figcaption id="caption-attachment-1409" class="wp-caption-text">The illusive Pagespeed insights 100/100 rating.</figcaption></figure>
<p>&nbsp;</p>
<h2>Magento Pagespeed 100/100 rating</h2>
<p>Well unfortunately due to some core Magento design issues I think the answer is no, <strong>BUT</strong> &#8211; you should be able to achieve a green rating of at least 90 to 95.</p>
<p>The <a href="https://blog.gaiterjones.com/5-ways-to-improve-magento-page-speed/" target="_blank">last time I worked on Pagespeed optimisation</a> I achieved an <em>85</em> desktop rating for a Magento landing page, today I achieved a <em>93</em> rating by further optimising JavaScript, CSS and HTML.</p>
<h2>Magento Pagespeed Optimisation</h2>
<p>Google Pagespeed insights targets 5 main optimisation categories</p>
<ul>
<li>Stylesheets optimizations</li>
<li>Javascript files optimizations</li>
<li>Images optimizations</li>
<li>HTML optimizations</li>
<li>Tracking activity filters</li>
</ul>
<p>When you run the <a href="https://developers.google.com/speed/pagespeed/insights/" target="_blank">insights tool</a> these are the areas that will be looked at and reported on. Google will clearly tell you where your Magento store needs improvement, it is likely you will need to look at both your server configuration and Magento to address Pagespeed issues found by Magento.</p>
<p>Problems such as web server <a href="https://blog.gaiterjones.com/5-ways-to-improve-magento-page-speed/">compression not enabled, browser caching not enabled</a> and server response times will require changes to your web server setup or core server configuration.</p>
<p><a href="https://blog.gaiterjones.com/5-ways-to-improve-magento-page-speed/" target="_blank">Image optimisation</a> is achievable with free image tools.</p>
<p>&nbsp;</p>
<p>CSS, Javascript and HTML optimisation and full page caching requires some extra Magento tweeking.</p>
<p>&nbsp;</p>
<h2>Magento CSS, Javascript and HTML optimisation</h2>
<p>Depending on your Magento theme there can be a lot of javascript and CSS includes in your source html. Best practice is to configure Magento to combine CSS and Javascript into one file. You do this by enabling JavaScript and CSS merge in <em>System -&gt; Configuration -&gt; Advanced -&gt; Developer</em>. You should also then install <a href="https://github.com/fooman/speedsteradvanced" target="_blank">Fooman Speedster Advanced</a> which will also minify JavaScript and CSS.</p>
<p>This process works well,  but by default Magento will insert all your JS and CSS into the header of the rendered webpage. The best practice for any CSS or JavaScript that might block the rendering of the webpage (DOM) until they are loaded is to move the JavasScript to the footer of the page.</p>
<p>The Google Pagespeed insights tool will quite likely tell you that you have render blocking JS and CSS.</p>
<p><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-1410" src="https://blog.gaiterjones.com/wp-content/uploads/2015/08/pagespeed-render-blocking.png" alt="pagespeed-render-blocking" width="567" height="114" srcset="https://blog.gaiterjones.com/wp-content/uploads/2015/08/pagespeed-render-blocking.png 567w, https://blog.gaiterjones.com/wp-content/uploads/2015/08/pagespeed-render-blocking-440x88.png 440w, https://blog.gaiterjones.com/wp-content/uploads/2015/08/pagespeed-render-blocking-550x111.png 550w" sizes="(max-width: 567px) 100vw, 567px" /></p>
<p>There are ways of customising the layout of your theme to move certain JS and CSS source files to the footer, in practice this can be complicated because you need to ensure that the loading order of your JavasScript files does not change so that scripts or plugins with dependencies on other JS libraries still run.</p>
<p>The guys at <a href="https://github.com/mediarox/pagespeed" target="_blank">Mediarox </a>have developed a neat solution that simply does a big cut and paste on your html code, finding all JS script and CSS elements, removing them from the header of the html and placing them in the footer.</p>
<p>I was pretty skeptical at first as to how effective this would be, but after installing the module and testing it I couldn&#8217;t see any major problems. The Mediarox module doesn&#8217;t minify html which was something I had been working on, so I <a href="https://github.com/gaiterjones/magento-pagespeed" target="_blank">integrated my minify html module into theirs and forked it on github.</a></p>
<p>My minify module uses the minify code from the <a href="https://code.google.com/p/minify/" target="_blank">Minify </a>project. My version of magento-pagespeed is adapted to work with a modified <a href="https://github.com/gaiterjones/Lesti_Fpc" target="_blank">Lestis full page cache</a> and the Mediarox JS and CSS modules.</p>
<h2>Install magento-pagespeed</h2>
<p><em>modman clone https://github.com/gaiterjones/magento-pagespeed</em></p>
<p>Install the module and configure it at <em>System -&gt; Configuration -&gt; Advanced -&gt; Pagespeed.</em> Here you can enable or disable HTML Minify, JS and CSS optmisation individually. I also added an extra option to disable all modules for logged in users.</p>
<p>If you want to exclude any JS scripts from optimisation enable the exclude list option and add a regex to identify the script.</p>
<p>Magento-pagespeed optimises Magento JS, CSS and html, I then cache the optimised html with Lesti_FPC. When implemented correctly you will see debug comments in the source of the Magento webpage indicating which Pagespeed (PS) module optimisations took place:</p>
<p>&lt;!&#8211; +PS JS 28-08-2015 07:50:04 4ms &#8211;&gt;<br />
&lt;!&#8211; +PS MIN_HTML 28-08-2015 07:50:04 30ms &#8211;&gt;<br />
&lt;!&#8211; +FPC 28-08-2015 07:50:04 &#8211;&gt;</p>
<p>Here we see PS JS and PS MIN_HTML are enabled. The JS optimisation took 4ms, the HTML minify code took 30ms. the html was then cached by Lest_FPC.</p>
<p>Moving the JS to the footer really helps to improve render blocking and this is reflected by the <a href="http://dev.gaiterjones.com/magento/" target="_blank">Pagespeed Insights tool running on my dev site </a>:</p>
<p><img decoding="async" class="aligncenter size-large wp-image-1411" src="https://blog.gaiterjones.com/wp-content/uploads/2015/08/dev-page-speed-insights-581x620.png" alt="dev-page-speed-insights" width="550" height="587" srcset="https://blog.gaiterjones.com/wp-content/uploads/2015/08/dev-page-speed-insights-581x620.png 581w, https://blog.gaiterjones.com/wp-content/uploads/2015/08/dev-page-speed-insights-412x440.png 412w, https://blog.gaiterjones.com/wp-content/uploads/2015/08/dev-page-speed-insights-550x587.png 550w, https://blog.gaiterjones.com/wp-content/uploads/2015/08/dev-page-speed-insights.png 718w" sizes="(max-width: 550px) 100vw, 550px" /></p>
<p>We can see that there are still render blocking issues and you need to experiment with CSS optimisation for your theme, a side effect of moving all CSS to the footer is that your page may load with some default styles until the CSS is loaded, leading to an ugly transition from unstyled to styled elements on the page. You can see how highly these issues are ranked by Google, render blocking CSS and Javascript that could be further compressed by 2% (1.3 Kb) is costing me 7 points on the insight scale and stopping me from getting to 100/100.</p>
<p>Could I get to 100/100, probably but 93 is still a pretty good result I think.</p>
<p>&nbsp;</p>
<h3>Resources</h3>
<ul>
<li><a href="https://github.com/gaiterjones/magento-pagespeed" target="_blank">magento-pagespeed</a>
<ul>
<li>js, css, html optimisation module adapted from <a href="https://github.com/mediarox/pagespeed" target="_blank">Mediarox Pagespeed</a></li>
<li>installation
<ul>
<li>modman clone https://github.com/gaiterjones/magento-pagespeed</li>
</ul>
</li>
</ul>
</li>
<li><a href="https://github.com/gaiterjones/Lesti_Fpc" target="_blank">Lesti FPC</a>
<ul>
<li>adapted to work with magento-pagespeed</li>
<li>installation
<ul>
<li>modman clone https://github.com/gaiterjones/Lesti_Fpc</li>
</ul>
</li>
</ul>
</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gaiterjones.com/magento-google-pagespeed-jscsshtmlminify-optimisation/feed/</wfw:commentRss>
			<slash:comments>13</slash:comments>
		
		
			</item>
	</channel>
</rss>
