WordPress.org

Ready to get started?Download WordPress

Forums

Can WP hack restrict plug-in from global loading? (2 posts)

  1. ViennaMex
    Member
    Posted 4 years ago #

    Since WP knows 'where' it is--what page or post is being loaded--why after all of these editions and releases, month after month, year after year do so many popular plugins keep being written and approved for the official plugins site that call themselves up on every single page, loading superfluous js or css scripts when the plugin function is not even installed for that page?

    Why isn't WP as a matter of practice telling plugin writers to keep their functions out of the loop until actually used? Or is this a core flaw with how WP itself loads up associated scripts for all installed-activated plugins?

    Too many plugins throw their http calls into the loop in the header demanding to load unneeded js and css for every page even when they are not in use, simply activated in the control panel. I am trying to optimize my site and other php programs I use only load the appropriate scripts for the page and plugin used.

    Can I alter the scripts in these offending plugins with a simple modification that keeps them confined to the page that actually uses their functionality?

    contact-form-7
    Dagon Design Formmailer Script dd-formmailer/dd-formmailer.css
    /wp-content/plugins/flash-video-player/swfobject.js
    /wp-content/plugins/flv-embed/swfobject.js

  2. ide79
    Member
    Posted 4 years ago #

    I have the same problem. Lots of JS and CSS that should not be loaded in every page. There is a sollution for contac-form-7

    Put these to wp-config.php

    define ('WPCF7_LOAD_JS', false);
    define('WPCF7_LOAD_CSS', false);

    And to call WPCF7 in a page

    <?php
    	wpcf7_enqueue_scripts();
    	wpcf7_enqueue_styles();
    ?>

    Before wp_head() is called

    More info from contac-form-7 homepage > docs

Topic Closed

This topic has been closed to new replies.

About this Topic