Skip to content

Performance Improvements #4

@superdav42

Description

@superdav42

I'm intrigued by this project and toyed with creating something similar in the past. I'm wondering how strategy in the handler actually works. like in this example:
https://github.com/x-wp/di/blob/master/examples/simple-plugin/src/WC/Handlers/Product_Page_Handler.php#L24

#[Handler(
	tag: 'init',
	priority: 10,
	context: Handler::CTX_FRONTEND,
	strategy: Handler::INIT_JUST_IN_TIME,
	container: 'example',
)]
class Product_Page_Handler {

Would Handler::INIT_JUST_IN_TIME prevent the Product_Page_Handler class from being loaded until the 'woocommerce_single_product_summary' or 'woocommerce_before_add_to_cart' actions are called?

I want to avoid loading large classes with potentially long init steps unless they are actually used. is INIT_JUST_IN_TIME the only way to do this? What are the other strategies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions