Proper way to load styles using a child theme

If you want to prevent HELLO from loading it’s own styles, this is the code to paste and adjust in your child theme’s functions.php :

function hello_elementor_scripts_styles() {
    // Dequeue parent theme stylesheets
    wp_dequeue_style( 'hello-elementor' );
    wp_deregister_style( 'hello-elementor' );
    
    wp_dequeue_style( 'hello-elementor-theme-style' );
    wp_deregister_style( 'hello-elementor-theme-style' );
    
    wp_dequeue_style( 'hello-elementor-header-footer' );
    wp_deregister_style( 'hello-elementor-header-footer' );

    // Enqueue only child theme stylesheets or custom stylesheets as needed
    // Example:
    wp_enqueue_style(
        'child-theme-style',
        get_stylesheet_directory_uri() . '/style.css', // Adjust the path to your child theme stylesheet
        array(), // Dependencies
        HELLO_ELEMENTOR_VERSION // Version
    );
}
add_action( 'wp_enqueue_scripts', 'hello_elementor_scripts_styles', 20 ); // Set priority to 20

But unless you want to rewrite the whole theme’s styling, I dont’ see any valid reason to do so. Just let the parent theme load its stylesheets, and if you’re running after performance to the point where you want to prevent a single stylesheet from loading, you should avoid elementor altogether.

tech