Deregister Styles & Scripts: Contact Form 7, js_composer, etc.

Posted in: Newspaper
Post count: 43

Hello Tagdiv Team,

The following codes (see below) were added to the theme’s function.php. They don’t work.

Would you please advise if the codings below are incorrect or is there another alternative to removing the style and javascript for Contact Form 7 and JS Composer. Also the Newspaper/js/tagdiv_theme.min.js. They are slowing down the website speed.

CONTACT FORM 7
Both pages are using the default template. Visual composer was used to create the submit-an-event page, but not the ‘contact’ form.

// Deregister Contact Form 7 styles
add_action( ‘wp_print_styles’, ‘aa_deregister_styles’, 100 );
function aa_deregister_styles() {
if (is_page( array( ‘contact’, ‘submit-an-event’ ) ); {
wp_deregister_style( ‘contact-form-7’ );
}
}

// Deregister Contact Form 7 JavaScript files on all pages without a form
add_action( ‘wp_print_scripts’, ‘aa_deregister_javascript’, 100 );
function aa_deregister_javascript() {
if (is_page( array( ‘contact’, ‘submit-an-event’ ) ); {
wp_deregister_script( ‘contact-form-7’ );
}
}

add_action( ‘wp_print_styles’, ‘aa_deregister_styles’, 10 );
function aa_deregister_styles()
{
$td_use_page_builder = false;
if (method_exists(‘WPBMap’, ‘getShortCodes’)) {
$td_use_page_builder = true;

}

if ($td_use_page_builder == true) {
wp_deregister_style(‘js_composer_front’);
wp_deregister_script(‘js_composer_front’);

}
}

Below is are sample results from the web page speed test.

Defer parsing of JavaScript

https://abc.com/wp-content/themes/Newspaper/Newspaper/js/tagdiv_theme.min.js?ver=8.1 (171.7KiB)
https://abc.com/wp-includes/js/jquery/jquery.js?ver=1.12.4 (87.0KiB)
https://abc.com/ (22.2KiB of inline JavaScript)
https://abc.com/wp-content/plugins/js_composer/assets/js/dist/js_composer_front.min.js?ver=5.2.1 (15.5KiB)
https://abc.com/wp-content/plugins/contact-form-7/includes/js/scripts.js?ver=4.9 (7.9KiB)
https://abc.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1 (7.7KiB)
https://abc.com/wp-includes/js/wp-embed.min.js?ver=4.8.1 (1.2KiB)
https://abc.com/wp-includes/js/comment-reply.min.js?ver=4.8.1 (918B)

Remove query strings from static resources

https://abc.com/wp-content/plugins/contact-form-7/includes/css/styles.css?ver=4.9
https://abc.com/wp-content/plugins/contact-form-7/includes/js/scripts.js?ver=4.9
https://abc.com/wp-content/plugins/js_composer/assets/css/js_composer.min.css?ver=5.2.1
https://abc.com/wp-content/plugins/js_composer/assets/js/dist/js_composer_front.min.js?ver=5.2.1
https://abc.com/wp-content/themes/Newspaper/Newspaper/images/icons/newspaper-icons.woff?1
https://abc.com/wp-content/themes/Newspaper/Newspaper/images/icons/newspaper.woff?14
https://abc.com/wp-content/themes/Newspaper/Newspaper/js/tagdiv_theme.min.js?ver=8.1
https://abc.com/wp-content/themes/Newspaper/Newspaper/style.css?ver=8.1
https://abc.com/wp-includes/js/comment-reply.min.js?ver=4.8.1
https://abc.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1
https://abc.com/wp-includes/js/jquery/jquery.js?ver=1.12.4
https://abc.com/wp-includes/js/wp-embed.min.js?ver=4.8.1
https://abc.com/wp-includes/js/wp-emoji-release.min.js?ver=4.8.

Thank you very much.

Nik

Post count: 22421

Hello,

Please read this guide for page speed optimization: https://forum.tagdiv.com/how-to-make-the-site-faster/
As a note on speedbooster: https://forum.tagdiv.com/topic/tinymce-advanced-and-other-various-disabling-speed-boster/

Thank you!

Post count: 43

Thanks, Bogdan.

Nik

Viewing 3 posts - 1 through 3 (of 3 total)
The forum ‘Newspaper’ is closed to new topics and replies.