Skip to Content
Menu

styles_http2_server_push_header()

Adds a header for HTTP2 Server Push if available by the server.

PHP March 30, 2021

Usage

This function runs automatically, so it is not called manually. Is this incorrect?

Additional Notes

The Service Worker Nebula option must be enabled, and the service worker file must be in the proper location (default: root directory) for this function to send the HTTP2 Server Push headers.

This function requests a server push of all enqueued local CSS and JS files.

Was this page helpful? Yes No


    A feedback message is required to submit this form.


    Please check that you have entered a valid email address.

    Enter your email address if you would like a response.

    Thank you for your feedback!

    Source File

    Located in /libs/Optimization.php on line 298.

    No Hooks

    This function does not have any filters or actions available. Request one?
    PHP
            public function styles_http2_server_push_header(){
                if ( !$this->is_admin_page(true, true) && $this->get_option('service_worker') ){ //Exclude admin, login, and Customizer pages
                    $timer_name = $this->timer('HTTP2 Server Push Header (Styles)', 'start');
                    global $wp_styles;
    
                    foreach ( $wp_styles->queue as $handle ){
                        if ( wp_style_is($handle, 'registered') && !empty($wp_styles->registered[$handle]->src) ){ //If this style is still registered (and src exists)
                            $ver = ( !empty($wp_styles->registered[$handle]->ver) )? '?ver=' . $wp_styles->registered[$handle]->ver : '';
                            $this->http2_server_push_file($wp_styles->registered[$handle]->src . $ver, 'style');
                        }
                    }
    
                    $timer_name = $this->timer($timer_name, 'end');
                }
            }
    

    Override

    This function can not be short-circuited with an override filter. Request one?