P
P
Petr Volkhanov2018-11-30 12:26:40
Accelerated Mobile Pages
Petr Volkhanov, 2018-11-30 12:26:40

How to exclude a function from executing on AMP pages in Wordpress?

How to exclude a function from executing on AMP pages in Wordpress?

if (!(is_admin() && is_amp_endpoint())) {
    function defer_parsing_of_js ( $url ) {
        if ( FALSE === strpos( $url, '.js' ) ) return $url;
        if ( strpos( $url, 'jquery.js' ) ) return $url;
        return "$url defer=\"defer\"";
    }
    add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
}

Why does this code work on AMP pages? How to fix it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question