Site logo

Archived topic

Can not delay navigation-search.min.js

5 replies · Started by Kee on June 21, 2021

Viewing posts 1–6 of 6

Hi,
I am using GP with Ezoic. I enabled "script delay" option on Ezoic to improve LCP and it works. But only "/generatepress/assets/js/navigation-search.min.js?ver=3.0.3" still marked as "avoid chaining critical requests". I contacted Ezoic support team and they told me "There are some Generate Press theme settings which can't be fully optimised by Ezoic because of the way they've been configured by Generate Press, so for example Ezoic can be delaying these scripts but if GeneratePress are layering other settings on top of that then the optimisations Ezoic is doing for this script may not work optimally"

I would like to know why this js is different from others? It seems Ezoic add an attribute "type=text/ez-screx" to delay the script.

Best regards
Kee

Hi there,

that script is enqueued like all other scripts in GP. I am not sure how Ezoic is applying there code but if it works for the other theme scripts there is no reason it should not work for that one.

Hi David,
Yes it looks weird. Can I add the attribute "type=text/ez-screx" to navigation-search.min.js manually? I tried to use script_loader_tag but not worked.

Thanks for your help.

Hmmm... if they require the ez-screx="true" attribute then you could try this:

add_filter( 'script_loader_tag', 'add_screx_att_to_search_scipt', 10, 3 );
 
function add_screx_att_to_search_scipt( $tag, $handle, $src ) {
    if ( 'generate-navigation-search' === $handle ) {
        $tag = '<script type="text/javascript" src="' . esc_url( $src ) . '" id="generate-navigation-search-js" ez-screx="true"></script>';
    }
 
    return $tag;
}

Hi,
Thanks very much David. It could be delayed now :)

Glad to hear that - it would be nice to hear if it made any tangible performance improvement :)

This archived topic is closed to new replies.