• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Contact Form 7 | Loading JavaScript and Stylesheet Only When it is Necessary.

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Contact Form 7 | Loading JavaScript and Stylesheet Only When it is Necessary.

This topic is: not resolved

Tagged: Contact Form 7, css, javascript

  • This topic has 4 replies, 2 voices, and was last updated 9 years, 3 months ago by hem.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • September 15, 2016 at 3:45 am #193183
    hem
    Member

    Hello Everyone,

    I am looking for solutions to load contact form 7 JavaScript and Stylesheet Only When it is Necessary.
    By default contact form 7 will load JavaScript and Stylesheet on all the pages, Not I don't want to load JavaScript and Stylesheet on all the pages.
    I follow the instruction as given on http://contactform7.com/loading-javascript-and-stylesheet-only-when-it-is-necessary/
    But as mention in the article "Note that wpcf7_enqueue_scripts() and wpcf7_enqueue_styles() must be called before wp_head() is called."
    Please help me to achieve this.

    Thank you.

    https://www.techlila.com/contact/
    September 16, 2016 at 3:26 pm #193260
    Christoph
    Member

    Hi,

    Ren's tutorial should help: https://www.engagewp.com/limit-contact-form-7-javascript-specific-pages/

    Shouldn't be a problem to add wp_deregister_style for the stylesheet.


    https://www.christophherr.com | Genesis Customizations | Buy me a coffee

    September 16, 2016 at 11:47 pm #193275
    hem
    Member

    Hi Christoph,

    Thank you for your help.

    The javascript part is working fine. 🙂
    But the same thing for CSS is not working.
    I try to add below code in the same function.
    wp_deregister_style( 'contact-form-7-css' );
    wp_dequeue_style('contact-form-7-css');

    Please help me to remove CSS also.
    Thank you.

    September 19, 2016 at 8:05 am #193352
    Christoph
    Member

    Ok. Ren is using wp_print_scripts
    that won't help for styles.

    You'd have to add a similar code block that uses
    add_action( 'wp_print_styles', 'your_function_name');
    and add wp_deregister_style into that function.


    https://www.christophherr.com | Genesis Customizations | Buy me a coffee

    September 19, 2016 at 11:08 pm #193414
    hem
    Member

    HI Christoph,

    Thanks a lot for Help. 🙂
    Regards,

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble