Upgrade to Pro — share decks privately, control downloads, hide ads and more …

WordPress Greek Community - Meetup Thessaloniki 2 - Website Optimisation - Takis Bouyouris

WordPress Greek Community - Meetup Thessaloniki 2 - Website Optimisation - Takis Bouyouris

WordPress Greek Community

December 21, 2015
Tweet

More Decks by WordPress Greek Community

Other Decks in Programming

Transcript

  1. Who am I? Takis Bouyouris Software Engineer/Web Developer Co-founder @

    Nevma WordPress Greek Community WordPress Greek Athens Meetup <Hello_World/>
  2. What I do? I build websites and web apps mostly

    based on WordPress Not impressed!
  3. 3. Google says so Speed is a SEO ranking factor

    because it is good for the users! Webmaster Central Blog: http://googlewebmastercentral.blogspot.gr/2010/04/using-site-speed-in-web-search-ranking.html
  4. Good performance requires: The completion of a request in a

    fast -or perceived fast- timeframe, with a reliable and predictable outcome.
  5. Websites live on HTTP requests Phases in every HTTP request:

    .1 – Browser => => 2 – Network => => 3 – Server => => 4 – Network => => 5 – Browser.
  6. In order to optimise a website you need to optimise

    all three: 1 – Server side 2 – Network layer 3 – Browser side
  7. 1. Server Performance Operating System File system Database layer Web

    server Application layer (more of a system admin's job)
  8. 2. Network performance DSL, ADSL, VDSL 2G, 3G, 4G, HSDPA

    WiFi, Ethernet etc Cannot do much about that, it does not depend on the web developer.
  9. 3. Browser performace Where frontend developers -should- shine! phase-1 :

    until page has loaded phase-2 : after page has loaded
  10. First, we need a tool to measure website performance All

    modern browsers have Developer Tools with a Network tab!
  11. But the best way is via an online service which

    - is objective - has stable conditions - provides good metrics
  12. Why Webpagetest.org - Real machines - Real browsers - Simulated

    networks - Stable, uniform conditions - Cities, devices, options - Open source
  13. Keep server side healthy - Secure your OS - Perform

    regular updates on OS, app server, db server - Keep as less files as possible especially images, even gifs - Database garbage cleanups - Database tables optimisation
  14. Also, server side - Allow HTTP keep-alive - Enable GZIP

    for texts - Avoid 404 requests - Use multiple domains - Avoid redirects
  15. WordPress specific server tips - Delete old post revisions -

    Delete auto drafts - Delete spam comments - Delete unused terms - Set revisions not too often - Set number of revisions low - Use few custom image sizes - Cleanup old sticky posts - Delete orphaned post meta - Avoid frequent hooks and filters like "pre_get_posts" - Avoid long taxonomy "not-ins" - Remove unused plugins - Remove unused themes
  16. Keep your code clean - Write quality code which is

    fast and maintainable - Choose quality addons themes, plugins, etc - Test early, test often
  17. Assuming your web server is not too slow and the

    network is not holding you back...
  18. Rule No 1 again Seriously make as few and quick

    HTTP requests possible! GIF on the right is there just to draw your attention Did it?
  19. Put CSS in the HEAD - Is downloaded asynchronously -

    Helps browsers start rendering page as often as possible * Except for "critical" CSS
  20. Put JS before BODY end - Javascript is "blocking" everything

    else - Helps browsers start rendering page as early as possible
  21. Compress images - Think of mobile devices, too - JPEG

    should be preferred - JPEG sizes can be reduced - PNG colours can be reduced - WebP, the new kid on the block (Many tools online for this)
  22. Use image sprites - Combines many images into one -

    Smaller file sizes - Less HTTP requests
  23. Use SVGs and fonts - Scalable vector graphics - One

    file, one download - Scales at any size But, be careful, too many of them can slow down your browser!
  24. Rule No 2 Cache as much as you can and

    for as long as possible
  25. Cache on the server - Cache whole requests - Use

    object cache in WP - HTML fragment cache in WP - Use query cache in DB - Opcode caching in PHP
  26. Cache on the browser Favicons -almost- never change Font files

    -almost- never change Styles and scripts rarely change Images also very rarely change HTML might change (but it depends) Be prepared to un-cache (invalidate) content
  27. # Expires headers – sent to browsers Cache-Control : max-age=900

    Date : Fri, 18 Dec 2015 14:12:57 GMT Expires : Fri, 18 Dec 2015 14:27:56 GMT ==> # Example .htaccess code part - Apache ExpiresDefault "access plus 1 week" ExpiresByType text/html "access plus 1 day" ExpiresByType text/css "access plus 1 month" ExpiresByType text/javascript "access plus 1 month" ExpiresByType image/jpg "access plus 3 months" ExpiresByType image/png "access plus 3 months" ExpiresByType font/opentype "access plus 6 months"
  28. Use a caching server (like Varnish) and/or a CDN not

    only because it's fast, also because it is distributed
  29. If ye be a hipster - SPDY, HTTP2, HTTPS -

    Content prefetching - DNS prefetching - SCRIPTs 'async' and 'defer' (Google them)
  30. Just remember a) Make as few HTTP requests as possible

    b) Cache as much as you can for as long as you can c) Everything I said is already available online