Contact Form 7 Ke CSS & JS Ko Only Contact Us Page Me Load Kaise Kare

Contact Form 7 Ke CSS & JS Ko Only Contact Us Page Me Load Kaise Kare

Hello Friends, it is very important to have a Contact Us page in the blog. Almost all bloggers maintain this page in their blog. There are many plugins available for this but the most popular Contact Form 7 Plugin is. If you are a wordpress user then you must have heard about it. If you use this plugin in your blog, then this post will prove useful for you. Because we are going to tell you in this post how to load JS and CSS of Contact Form 7 only in the “Contact Us” page? So that site loads fast.
Wordpress contact form 7 scripts unload
When we create a blog, it has to be setup properly before writing an article in it. Along with design, some important pages have to be added. Such as About Us, Contact Us, Privacy and Policy etc. Having these pages in the blog is very important. You can easily create about us and privacy and policy page. But to create a form in the contact us page, one has to use script or plugin.
It is very important to have a contact us page in the blog. There can be many reasons for this but not one. This makes our visitors, clients and customers contact us. Almost all bloggers maintain contact us page in their blog. You can easily create contact us form by using Script in Blogger. But you have to use the plugin for WordPress.
Contact From 7 plugin is the most popular and good for creating contact us form in WordPress blog. I have also used this plugin before. Currently, I use Google Form for contact form in my blog. If you use the contact form 7 plugin in your blog, then this post will be very important for you.
Actually, when we use the CF7 plugin in the blog, its javascript and css start loading in all posts and pages. Due to which our site starts loading very slow. While CF7's javascript and css are needed only in the contact us page, there is no benefit of loading it in all the other pages. I stopped using this plugin for the same reason.
If you would be checking the loading speed of the site in pingdom or any other tool, you would see that js and css of CF7 would be loaded there. You will also be able to see in the source code of your site that there example.com/wp-content/plugins/contact-form-7/includes/css/style.css Will be a URL like. Similarly, there will be another URL which contains javascript load.
If your site is slow loading, then this plugin can also be the reason. But you do not worry We are going to tell you a solid way by which you can prevent CF7 scripts from loading in the rest of the page except contact us page.
We will give you some lines of code that you will need to add to your theme's functions.php. After that, except for the contact us page in your blog, the js and css file of CF7 will stop loading in all pages and posts of Contact Form 7 in the rest of the pages.

Apart from Contact Us Page in the blog, how to prevent the contact form 7 from being scripted?

In the way I have also told you above that for this you have to add some lines to the code functions.php. But you have to find the id of your contact us page and add it to the code. If you do not know the id of your contact us page then below we are telling about it below.

How to Find Page ID?

  1. Login to Dashboard and go to Pages »All Pages.
  2. Now click on Edit under the page whose ID you want to find.
how to find post or page id in wordpress
Now you will see in Browser's URL bar that there will be some such URL.
https://www.blogginghindi.com/wp-admin/post.php?post=2& action = edit
Here you can see that post = 2 That means my page id is 2. Similarly, your URL will also contain. Your URL may contain another number instead of 2. Note down the id of your contact us page.
Now you have found the page id. After that, now follow the steps given below.
First login to the blog and Dashboard »Appearance» Editor By going to Functions.php Open it Now you copy the below code and add it to Functions.php and Save changes Click on
Note: over here if (! is _ page (2)) Replace the id of your contact us page with 2 in the line next to it. Otherwise it will not work.

function load_contactform7_on_specific_page () {
   // Edit page IDs here
   if (! is_page (2))
   {
      wp_dequeue_script ('contact-form-7'); // Dequeue JS Script file.
      wp_dequeue_style ('contact-form-7'); // Dequeue CSS file.
   }
}

add_action ('wp_enqueue_scripts', 'load_contactform7_on_specific_page');
Now you can check the source code of your blog. Now script loading of contact form 7 plugin from other pages will stop. If you are having any problem, then comment in the comment box below.
Please! Share this post on Social Media.

Comments