I have a new method to optimize for google CWV (Core Web Vitals). Here I will show you.
WP-Optimize
After activating enable caching. Check generate separate files for mobile devices. Go to the preload tab and check activate scheduled cache preloading.
PhastPress
Just activate and let it do its thing.
Page Optimize
Just activate and let it do its thing.
Specify Missing Image Dimensions
Just activate and let it do its thing.
Pre* Party Resource Hints
Just activate and let it do its thing.
EWWW image optimizer
Go to your settings and then webp tab. Check webp conversion. Finally go to media and then bulk optimize. Let it compress your images.
COAS
Just enter your google analytics tracking id and you are good to go.
Asset Cleanup
Use devtools code coverage to see what scripts are not used on pages likes the front and exclude them.
Browser cache
Put this anywhere in .htaccess of your document root.
# Begin Leverage Browser Caching <IfModule mod_mime.c> AddType text/css .css AddType text/x-component .htc AddType application/x-javascript .js AddType application/javascript .js2 AddType text/javascript .js3 AddType text/x-js .js4 AddType text/html .html .htm AddType text/richtext .rtf .rtx AddType text/plain .txt AddType text/xsd .xsd AddType text/xsl .xsl AddType text/xml .xml AddType video/asf .asf .asx .wax .wmv .wmx AddType video/avi .avi AddType image/bmp .bmp AddType application/java .class AddType video/divx .divx AddType application/msword .doc .docx AddType application/vnd.ms-fontobject .eot AddType application/x-msdownload .exe AddType image/gif .gif AddType application/x-gzip .gz .gzip AddType image/x-icon .ico AddType image/jpeg .jpg .jpeg .jpe AddType image/webp .webp AddType application/json .json AddType application/vnd.ms-access .mdb AddType audio/midi .mid .midi AddType video/quicktime .mov .qt AddType audio/mpeg .mp3 .m4a AddType video/mp4 .mp4 .m4v AddType video/mpeg .mpeg .mpg .mpe AddType video/webm .webm AddType application/vnd.ms-project .mpp AddType application/x-font-otf .otf AddType application/vnd.ms-opentype ._otf AddType application/vnd.oasis.opendocument.database .odb AddType application/vnd.oasis.opendocument.chart .odc AddType application/vnd.oasis.opendocument.formula .odf AddType application/vnd.oasis.opendocument.graphics .odg AddType application/vnd.oasis.opendocument.presentation .odp AddType application/vnd.oasis.opendocument.spreadsheet .ods AddType application/vnd.oasis.opendocument.text .odt AddType audio/ogg .ogg AddType application/pdf .pdf AddType image/png .png AddType application/vnd.ms-powerpoint .pot .pps .ppt .pptx AddType audio/x-realaudio .ra .ram AddType image/svg+xml .svg .svgz AddType application/x-shockwave-flash .swf AddType application/x-tar .tar AddType image/tiff .tif .tiff AddType application/x-font-ttf .ttf .ttc AddType application/vnd.ms-opentype ._ttf AddType audio/wav .wav AddType audio/wma .wma AddType application/vnd.ms-write .wri AddType application/font-woff .woff AddType application/font-woff2 .woff2 AddType application/vnd.ms-excel .xla .xls .xlsx .xlt .xlw AddType application/zip .zip </IfModule> <IfModule mod_expires.c> ExpiresActive On ExpiresByType text/css "access plus 1 year" ExpiresByType text/x-component "access plus 1 year" ExpiresByType application/x-javascript "access plus 1 year" ExpiresByType application/javascript "access plus 1 year" ExpiresByType text/javascript "access plus 1 year" ExpiresByType text/x-js "access plus 1 year" ExpiresByType text/html "access plus 1 month" ExpiresByType text/richtext "access plus 1 month" ExpiresByType text/plain "access plus 1 month" ExpiresByType text/xsd "access plus 1 month" ExpiresByType text/xsl "access plus 1 month" ExpiresByType text/xml "access plus 1 month" ExpiresByType video/asf "access plus 1 year" ExpiresByType video/avi "access plus 1 year" ExpiresByType image/bmp "access plus 1 year" ExpiresByType application/java "access plus 1 year" ExpiresByType video/divx "access plus 1 year" ExpiresByType application/msword "access plus 1 year" ExpiresByType application/vnd.ms-fontobject "access plus 1 year" ExpiresByType application/x-msdownload "access plus 1 year" ExpiresByType image/gif "access plus 1 year" ExpiresByType application/x-gzip "access plus 1 year" ExpiresByType image/x-icon "access plus 1 year" ExpiresByType image/jpeg "access plus 1 year" ExpiresByType image/webp "access plus 1 year" ExpiresByType application/json "access plus 1 year" ExpiresByType application/vnd.ms-access "access plus 1 year" ExpiresByType audio/midi "access plus 1 year" ExpiresByType video/quicktime "access plus 1 year" ExpiresByType audio/mpeg "access plus 1 year" ExpiresByType video/mp4 "access plus 1 year" ExpiresByType video/mpeg "access plus 1 year" ExpiresByType video/webm "access plus 1 year" ExpiresByType application/vnd.ms-project "access plus 1 year" ExpiresByType application/x-font-otf "access plus 1 year" ExpiresByType application/vnd.ms-opentype "access plus 1 year" ExpiresByType application/vnd.oasis.opendocument.database "access plus 1 year" ExpiresByType application/vnd.oasis.opendocument.chart "access plus 1 year" ExpiresByType application/vnd.oasis.opendocument.formula "access plus 1 year" ExpiresByType application/vnd.oasis.opendocument.graphics "access plus 1 year" ExpiresByType application/vnd.oasis.opendocument.presentation "access plus 1 year" ExpiresByType application/vnd.oasis.opendocument.spreadsheet "access plus 1 year" ExpiresByType application/vnd.oasis.opendocument.text "access plus 1 year" ExpiresByType audio/ogg "access plus 1 year" ExpiresByType application/pdf "access plus 1 year" ExpiresByType image/png "access plus 1 year" ExpiresByType application/vnd.ms-powerpoint "access plus 1 year" ExpiresByType audio/x-realaudio "access plus 1 year" ExpiresByType image/svg+xml "access plus 1 year" ExpiresByType application/x-shockwave-flash "access plus 1 year" ExpiresByType application/x-tar "access plus 1 year" ExpiresByType image/tiff "access plus 1 year" ExpiresByType application/x-font-ttf "access plus 1 year" ExpiresByType application/vnd.ms-opentype "access plus 1 year" ExpiresByType audio/wav "access plus 1 year" ExpiresByType audio/wma "access plus 1 year" ExpiresByType application/vnd.ms-write "access plus 1 year" ExpiresByType application/font-woff "access plus 1 year" ExpiresByType application/font-woff2 "access plus 1 year" ExpiresByType application/vnd.ms-excel "access plus 1 year" ExpiresByType application/zip "access plus 1 year" </IfModule> # End Leverage Browser Caching
Security headers
Put this anywhere in .htaccess of your document root.
# Security headers <IfModule mod_headers.c> Header set Referrer-Policy "strict-origin-when-cross-origin" Header set X-XSS-Protection "1; mode=block" Header set X-Content-Type-Options "nosniff" Header set X-Frame-Options "SAMEORIGIN" Header set Strict-Transport-Security "max-age=31536000" Header unset X-Powered-By </IfModule> # End Security headers
Text compression
Put this anywhere in .htaccess of your document root.
# text compression <IfModule mod_deflate.c> # Compress HTML, CSS, JavaScript, Text, XML and fonts AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/vnd.ms-fontobject AddOutputFilterByType DEFLATE application/x-font AddOutputFilterByType DEFLATE application/x-font-opentype AddOutputFilterByType DEFLATE application/x-font-otf AddOutputFilterByType DEFLATE application/x-font-truetype AddOutputFilterByType DEFLATE application/x-font-ttf AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE font/opentype AddOutputFilterByType DEFLATE font/otf AddOutputFilterByType DEFLATE font/ttf AddOutputFilterByType DEFLATE image/svg+xml AddOutputFilterByType DEFLATE image/x-icon AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/xml # Remove browser bugs (only needed for really old browsers) BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html Header append Vary User-Agent </IfModule> # end text compression
Responsive images
Use responsive add_image_size()
add_image_size( 'mobile-first', <width>, <height> ); the_post_thumbnail( ( wp_is_mobile() ? 'mobile-first' : 'full' ) );
Exclude iPad from wp_is_mobile()
function myprefix_exclude_ipad( $is_mobile ) { if (strpos($_SERVER['HTTP_USER_AGENT'], 'iPad') !== false) { $is_mobile = false; } return $is_mobile ; } add_filter( 'wp_is_mobile', 'myprefix_exclude_ipad' );
Litespeed
Do not use wp-optimize cache or ewww image optimizer webp htaccess rules. Do not use other htaccess rules mentioned. Use Litespeed cache plugin for cache and browser cache with webp htaccess rules. Leave ewww image optimizer webp function enabled and use to generate.
Now keep in mind there are likely ways you can tune your site even more and with these plugins. Each case is different. These are general ways to improve every site.