Frontend Performance Optimiziation

Step by Step with Symfony2

SunshinePHP, Feb 8th 2013 © David Buchmann, Liip AG

About David Buchmann

Twitter: @dbu

David is a senior developper at Liip SA, specializing in Symfony2. He happens to also be a certified Scrum Master and sometimes enjoys doing the scrum master or product owner role for a project.

Liip is doing custom web development with PHP in Switzerland.

What makes a website slow?

What makes a website slow?


Measure - change - measure

Jordi Boggiano



Understand the effects of your changes.



Remember:

«Premature optimization is the root of all evil»

Donald E. Knuth

I am going to talk about

  1. Frontend performance analysis and basic tips
  2. Assetic to get serious about css and js optimization
  3. Caching
  4. Varnish and ESI

I am not going to talk about

Overview

  1. Frontend performance analysis and basic tips
  2. Assetic to get serious about css and js optimization
  3. Caching
  4. Varnish and ESI

Tools and helpers

The demo application


github.com/dbu/symfony-speed

Demo application

Measure

Measure

About 10 seconds until the user sees a page

Optimization: Move javascript to the bottom

# layout.html.twig
@@ -6,8 +6,6 @@
    {% include 'DbuCoreBundle::stylesheets.html.twig' %}
-   {% include 'DbuCoreBundle::javascripts.html.twig' %}
    <link rel="shortcut icon" href="{{ asset('favicon.ico') }}" >
  </head>

@@ -91,5 +89,11 @@
    </div>
+   {# javascript at the bottom: browser waits with rendering
+      until all files referenced before are loaded
+   #}
+   {% include 'DbuCoreBundle::javascripts.html.twig' %}

</body>