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

Advanced Web Performance Optimization

Advanced Web Performance Optimization

If your website is slow, the user won’t give a second thought before leaving your site. A dissatisfied user is worst than not getting traffic at all! This workshop mainly deals with how one can perform web performance optimization of their WordPress website, thus improving conversions and sales.

It begins with discussing performance-related woes, how to measure them and what are the solutions for different scenarios. Further, the discussion will be about different performance optimization strategies like cutting down and optimization of queries, tweaking code base, implementing caching, use of various cloud services including concepts like scaling up and scaling forward strategies.

Further, there will be discussion and hands-on exercise of advanced performance optimization techniques like transients API, fragment caching, planning caching strategy, profiling, assets offloading, assets optimization and so on.

Vineet Talwar

April 09, 2022
Tweet

More Decks by Vineet Talwar

Other Decks in Technology

Transcript

  1. 3

  2. 23 Testing • Tools.pingdom.com • Page Speed Insights • Lighthouse

    test (web.dev/measure) • Gtmetrics • Chrome devtools @vineetsktalwar
  3. 29 Lazy Loading § Lazy loading offscreen images with JS

    § <img loading=“lazy”> § WordPress core (5.5 onwards) supports lazy loading § Libraries: Lozad.js or Lazysizes § Define Height, Width Attribute to images explicity to decrease CLS https://web.dev/browser-level-image-lazy-loading/ @vineetsktalwar
  4. 33 Images CDN • S3+ CloudFront • Digital Ocean Spaces

    • Jetpack Photon • Akamai CDN • Fastly • Plugins: W3 Total Cache, WP Offload S3 @vineetsktalwar
  5. 35 Fonts Font Swap – http://fonts.googleapis.com/ css?family=Roboto&font- display=swap • @font-face

    { • font-family: ‘custom font’; • src: url(..); • font-display: swap; • } @vineetsktalwar
  6. 37 Caching • Page Cache • Browser Cache • Object

    Cache • Database Cache • Transient Cache • Opcache, Redis, Memcached • Plugins: W3 Total Cache, WP Super Cache @vineetsktalwar
  7. 38 Plan it out • Use case • Estimate traffic

    • Expectations from visitors • User Retention • Test as your end user • Think abut mobile users first • A/B Test • Hotjar Test @vineetsktalwar
  8. 41 Query time • Queries are slow • Multi Dimension

    Meta Queries • Multi Dimension Taxonomy Queries @vineetsktalwar
  9. 43 Transient Cache • set_transient( 'foo_featured_posts', $featured, 12 * HOUR_IN_SECONDS

    ); • get_transient( 'foo_featured_posts’ ) • ‘set_site_transient()’ • ‘wp transient delete-expired’ @vineetsktalwar
  10. Example: <?php // Check for transient. If none, then execute

    WP_Query if ( false === ( $featured = get_transient( 'foo_featured_posts' ) ) ) { $featured = new WP_Query( array( 'category' => 'featured', 'posts_per_page' => 5 ) ); // Put the results in a transient. Expire after 12 hours. set_transient( 'foo_featured_posts', $featured, 12 * HOUR_IN_SECONDS ); } ?> // Run the loop as normal <?php if ( $featured->have_posts() ) : ?> <?php while ( $featured->have_posts() ) : $featured->the_post(); ?> // featured posts found, do stuff <?php endwhile; ?> <?php else: ?> // no featured posts found <?php endif; ?> <?php wp_reset_postdata(); ?> Using Transients with WP_Query to retrieve featured posts
  11. 49

  12. 55 Adaptive serving • Data saver mode / Light Applications

    • Slow network specific version • Offline first @vineetsktalwar
  13. 58 Javascripts • High bootup time • Defer Third Party

    Embeds • Obese Expensive Libraries • Split the Code • Preload, preconnect, prefetch, dns-prefetch • Minify, Automate minification @vineetsktalwar
  14. 59 Tracking Scripts • Tracking based with GTM. • Block

    Tracking scripts, before cookies are accepted. • Load Async • Scripts On Window Load • OneTrust, Cookiebot @vineetsktalwar
  15. 60 Minify • Minify CSS, Minify JS • Optimize libraries

    with webpack: GoogleChromeLabs/webpack-libs-optimizations • Plugins: Autoptimize, W3 Total Cache @vineetsktalwar
  16. 62 Resource Hints • Preconnect Critical Origin • Preload Critical

    Scripts • Prefetch Visible Links • Priority Hints (For Future) @vineetsktalwar
  17. 64 Scaling Servers • Scale Up and Scale Forward •

    Load Balancer Architecture • Serverless if and when possible • Elasticsearch for queries (Elasticpress Plugin) @vineetsktalwar
  18. 66 What else ? • Bloats • Unwanted Plugins •

    Optimize DB • Cleanup wp-admin • Expiry Header @vineetsktalwar
  19. Vineet Talwar Product Owner / Web Developer E-Mail: [email protected] Twitter:

    @vineetsktalwar Linkedin: /in/vineetsktalwar Podcast: wpshoutout.com Speakerdeck: @vineetsktalwar Slides available: https://src.hm/wordcampgeneve