Grow your CSS skills. Land your dream job.

Load plugin on specific page only

  • # December 24, 2012 at 7:39 am

    I have plugin I would like to use only on the contact page, however the script and css is being loaded on every page. Aside from the increased http requests, it is also causing another script to not work properly on another page.

    Is there a way to stop this plugin from loading anywhere else on the site?

    I know how to do this with normal scripts in the header, but I am not sure how to do this with a plugin that automatically injects scripts into the header.

    Thanks in advance.

    # December 24, 2012 at 7:49 am

    Is the site WordPress because if it is there is a good plugin to to it called “Art Direction”.
    I hope this is helpful to you.

    # December 24, 2012 at 9:10 am

    You can simply do this with a PHP if-statement. I wouldn’t use a plugin for this.

    If is contact page > echo this script

    # December 24, 2012 at 9:19 am

    @Htmlmainiac thanks but I don’t think that’s the purpose of that plugin. Yeh @chrisburton I decided to go with this solution…

    http://contactform7.com/loading-javascript-and-stylesheet-only-when-it-is-necessary/

    You edit the wp.config file with the scripts you wish to not load…

    define(‘WPCF7_LOAD_JS’, false);

    …and then manually enqueue them on the pages you wish to load the script.

    # December 24, 2012 at 9:23 am

    Nice.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".