Skip to content

Instantly share code, notes, and snippets.

View mukeshpanchal27's full-sized avatar
🎯
Focusing

Mukesh Panchal mukeshpanchal27

🎯
Focusing
View GitHub Profile
@mukeshpanchal27
mukeshpanchal27 / README.md
Last active October 1, 2024 09:48
POC: image sizes calculation using column context

WPP Column Context Plugin

Description

The WPP Column Context Plugin is a proof of concept (POC) WordPress plugin that demonstrates how to extend block context for core/columns and core/column blocks and dynamically calculate responsive image sizes based on column widths. The plugin adds custom context keys for columns and column widths, allowing block types like core/image to access this information when rendering.

Installation

  1. Download the plugin and place it in your WordPress wp-content/plugins/ directory.
  2. Activate the plugin through the WordPress admin dashboard.
@mukeshpanchal27
mukeshpanchal27 / wpp-prime-attachment-cache.php
Last active September 12, 2024 13:45
MU plugin for priming the attachment cache for WordPress
<?php
/**
* Plugin Name: WPP Prime Attachment Cache
* Description: MU plugin for priming the attachment cache.
* Version: 1.0
*/
/**
* Primes attachment into the cache with a single database query.
*
@mukeshpanchal27
mukeshpanchal27 / README.md
Created September 4, 2024 08:42
WPP Group Context checking

WPP Group Context

Result array:

[context] => Array
(
    [postId] => 7
    [postType] => page
)
@mukeshpanchal27
mukeshpanchal27 / README.md
Created September 4, 2024 08:32
WPP Column Context checking

WPP Column Context

Result array:

[context] => Array
(
    [col-width] => 100%
    [postId] => 7
 [postType] =&gt; page

Benchmark for locate_template

Profile a modified version of locate_template to see if we can speed it up.

See PR WordPress/wordpress-develop#6502

Result: Overall, the new_locate_template() function shows a performance decrease ranging from 29.5% to 109.7% compared to the locate_template() function in most cases.

Average time spent for 1 x 1000 iterations: locate_template() - 2327291 new_locate_template() - 3371709 Change: 44.9%
@mukeshpanchal27
mukeshpanchal27 / README.md
Last active August 23, 2024 08:41
WPP Column Image Sizes is a proof of concept WordPress plugin that provides a better calculation for nested image block in columns.

WPP Column Image Sizes

This is a WordPress Plugin that improves the default sizes attribute calculation for nested image block in columns.

Benchmark for auto_sizes_update_content_img_tag

Profile a modified version of auto_sizes_update_content_img_tag to see if we can speed it up.

See PR WordPress/performance#1471

Result: This comparison shows that while both functions( Current and new that uses WP_HTML_Tag_Processor) are very fast, the new function (Use with WP_HTML_Tag_Processor) still takes almost twice the time to execute compared to the first function, as reflected in the ~97% increase in time.

Average time spent for 1000 x 1 iterations: auto_sizes_update_content_img_tag() - 9.1886520385742E-7 auto_sizes_update_content_img_tag_with_html_tag_processor() - 1.8219947814941E-6 Change: 98.3%
@mukeshpanchal27
mukeshpanchal27 / README.md
Created November 6, 2023 09:24
Profile a modified version of `get_query_template` to see if we can speed it up.

Benchmark for get_query_template

Profile a modified version of get_query_template to see if we can speed it up.

This is used to benchmark the patch introduced for Trac ticket #59315.

Average time spent for 10 x 18 iterations.

TT3 ( Block theme )

Benchmarks for WP 6.3.2 > 6.4-RC2

The following profiling runs were run locally on my computer using the compare-wp-performance script, comparing WP 6.3.2 to 6.4-RC2. An automated run using GH actions can be found here:

Run 1

Web Vitals (Block Theme)

| Metric | Before | After | Diff % | Diff abs. |

@mukeshpanchal27
mukeshpanchal27 / WP-6.3.2-6.4-RC1.md
Created October 18, 2023 12:53
WP 6.4-RC1 Benchmarks