WordPress Optimization Tip
Wasif Hameed
Wordpress Developer @ Digitalis Global | Bachelor's in Computer Science
Boosting your WordPress website's performance is crucial for providing a seamless user experience and securing higher rankings on search engines like Google. While cache plugins play a significant role in speeding up your site, there are additional manual steps you can take to further enhance its performance.
One common contact form plugin used on websites is Contact Form 7. We often enable reCaptcha in the plugin to protect the form from bot submissions. However, have you noticed that the plugin code is executed on every page, even on those where the form is not being used? If you haven't noticed yet, take a quick look at the bottom right of your screen, and you'll spot the reCaptcha icon there.
To optimize the loading of plugin files and only load them on the pages where the contact form is actually used, you can simply add the following code to your functions.php file:
function wpcf7_dequeue_redundant_scripts() {
??$post = get_post();
??if ( is_singular() && !has_shortcode( $post->post_content, 'contact-form-7' ) ) {
????wp_dequeue_script( 'contact-form-7' );
????wp_dequeue_style( 'contact-form-7' );
????wp_dequeue_script( 'wpcf7-recaptcha' );???
????wp_dequeue_style( 'wpcf7-recaptcha' );
????wp_dequeue_script( 'google-recaptcha' );
??}
}
add_action( 'wp_enqueue_scripts', 'wpcf7_dequeue_redundant_scripts', 99?
Feel free to contact me for your queries related to WordPress.
Email: [email protected]
Contact on Whatsapp: +923308530732
#WordPressOptimization #PluginPerformance #WPPlugins #WebsiteOptimization #WPDevelopment #CodeOptimization #PluginEfficiency #WebsiteSpeed #WordPressTips #WebPerformance #WPDeveloper #PluginOptimization #WordPressPlugins #WebsiteMaintenance #CodeEfficiency #PluginManagement #WordPressSpeed #WPBestPractices #OptimizedPlugins #WebsiteImprovement #linkedin
--
1 年https://www.upwork.com/freelancers/settings/profile
This is a great tip for optimizing Contact Form 7 plugin on WordPress! We'll definitely implement this code on our site to speed up our loading time.
Google Certified Digital Marketer ?? $1 Mil+ Ad-spend | Search Ads Expert | PPC | SEO Strategist | CRO for HVAC, Healthcare, Medical Billing | Web Design & AI Chatbots | MarTech Evangelist | Computer scientist
1 年Great info Wasif Hameed. Thanks for sharing. ??
Full Stack Web Developer
1 年This will help me
Flutter | Software Engineer
1 年Very helpful article for WordPress peeps