Git Product home page Git Product logo

wordpress-core-web-vitals-lab's Introduction

WordPress Core Web Vitals Lab

Core Web Vitals is a reality. These new metrics created to measure the user page experience will be part of the Google ranking algorithm in May 2021. The objective of this project is to be a laboratory of testing how the WordPress ecosystem bahaves with these metrics.

The objective of this project is to discuss how to improve the Lighthouse metrics on the WordPress ecosystem.

This configuration comes with Varnish to cache requests and reduce the server response time. For tests purpose, it is possible use or bypass it. See How to serve section to check how do that.

Docker Compose is the base to the configuration to serve the WordPress application. So, to run the project it is necessary to have Docker installed.

How to install

$ docker-compose build --pull && docker-compose pull
$ docker-compose run --rm composer install --ignore-platform-req php
$ docker-compose up -d db
$ docker-compose run --rm wordpress wp-install

How to serve

$ docker-compose up -d server

The WordPress application will be served on 4 ports:

  • 443: Varnish over SSL and HTTP/2
  • 80: Varnish over HTTP/1.1
  • 44380: Without Varnish over SSL and HTTP/2
  • 8080: Without Varnish over HTTP/1.1

Plugin

We have a plugin called Core Web Vitals Performance Optimize inner the project. This plugin has proof of concept to add page performance improvements to WordPress Core and the entire ecosystem.

This plugin is symlinked to the directory plugin and it is automatically activated by installation script.

Services

WordPress

A PHP image with the WordPress modules dependencies.

The image is built with WP-CLI to help manage the application. See How to run WP-CLI commands section to get more information how to use it.

It was added Xdebug extension to help debug the application. See How to debug section to see how to enable and config the integration with the IDE.

Nginx

Used to proxy the requests to Varnish and PHP-FPM.

Varnish

The cache system to delivery the requests faster than process them every time.

MariaDB

The database service to store application data.

Plugin test

Service to run Core Web Vitals Performance Optimize unit test. See How to run plugin unit tests section to see how run the tests.

Plugin coding standards

Service to check if the code standard of the plugin. See How to check plugin coding standards section to see how run the checker.

How To

How to run WP-CLI commands?

$ docker-compose run --rm wp [command]

How to debug?

It is necessary change the value of XDEBUG_MODE from off to debug on docker-compose.yml file and restart the WordPress service if it is already running.

$ docker-compose restart wordpress

For VS Code integration, the PHP Debug should be installed and active. The launch.json must have this configuration:

{
    "name": "Listen for XDebug",
    "type": "php",
    "request": "launch",
    "port": 9003,
    "pathMappings": {
        "/cwv-perf-optimize": "${workspaceRoot}/cwv-perf-optimize",
        "/var/www/html": "${workspaceRoot}/public",
    }
}

How to run plugin unit tests?

$ docker-compose run --rm plugin-tests

The unit tests images come with phpunit-watcher shipped to keep PHPUnit running and waiting changes to run the tests again.

$ docker-compose run --rm phpunit phpunit-watcher watch

How to check plugin coding standards?

$ docker-compose run --rm cs

To fix code alowed to be fixed using PHP Code Beautifier and Fixer.

$ docker-compose run --rm cs phpcbf

wordpress-core-web-vitals-lab's People

Contributors

edpittol avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

cjperes

wordpress-core-web-vitals-lab's Issues

Defer non-crititcal CSS

CSS files are render-blocking resource. They impact the page load. So, if the CSS resources is delayed, the page is loaded faster.

The challenge on this technique is to load the critical path CSS (above the fold) style preloaded. If it isn't done, we have a big trouble with Cumulative Layout Shift because the first load will be done without any style.

penthouse is a tool that allow you generate critical path CSS. Supplying the URL and the CSS content of the file, it is possible to get the critical path CSS. If shipped on the environment, it is possible generate the critical path for tests purpose.

Oportunity/Diagnotiscs:

Reference

Use swap as font-display to Google Fonts on Elementor

Elementor uses the function the class Elementor\Frontend::enqueue_google_fonts to enqueue the Google Fonts used on the website. It doesn't consider to use the font-display: swap to display a system font while the webfont is loaded.

The challenge is develop an otimization inner Cwv_Perf_Optimize\Elementor namespace to load Google Fonts on Elementor with font-display: swap property.

How to reproduce

  1. Download Duplicator zip package and installer.php
  2. Clone the project
  3. Create the public directory on the root of the project
  4. Make public directory writable: chmod 777 public/
  5. Move the Duplicator zip package and installer.php to public directory
  6. Up the server: docker-compose up -d server
  7. Access Duplicator installer: https://localhost/installer.php
  8. Run the installation process. Use db as database password
  9. Access admin to finish the process. The credentials are admin / admin
  10. Access the homepage: https://localhost/
  11. Go to Network tab on Developer Tool and filter by swap
  12. The list of request is empty

Expected

The Google Fonts request should be shown on request list when filtered by swap.

Reference

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.