WordPress.org

Ready to get started?Download WordPress

Forums

Limit plugin includes (css/javascript) to single page? (5 posts)

  1. briang
    Member
    Posted 4 years ago #

    Is there a way to limit plugin includes (js/css) to a single page?

    Most of my plugins are used on a single page (ie. Contact Form), yet these plugins are including it's javascript and css throughout my entire site. Not only is this causing excess load times, in some cases it causes conflict with other plugin scripts.

    Any ideas?

  2. oweninnamibia
    Member
    Posted 4 years ago #

    I have this problem too.... anyway around having the JS and CSS for a particular plugin only load on the page it's being used?

  3. smordue
    Member
    Posted 3 years ago #

    I too would like this answer, it would be nice if the page editor had a list of all plugins that you could check or uncheck by page to use or not.

  4. e-sushi
    Member
    Posted 3 years ago #

    Actually that's rather simple.

    1. Create a "header-2.php" or something like that including your extra css and js.
    2. Next, create a page template that includes the alternate header file INSTEAD of the regular "header.php".
    3. Finally, use that page template to do your contact form stuff and co.

    Done - mission accomplished!

  5. e-sushi
    Member
    Posted 3 years ago #

    An alternative would be use 2 header files. The original "header.php" that is included in every theme file... and in a page template, an additional include of an "additional-header-file.php" (name it yourself) that contains only the JS and CSS you need/want to add to your header.

    (Just Saying)

Topic Closed

This topic has been closed to new replies.

About this Topic