• Hello,

    I don’t know if there is a solution for this but i’m going to rant on about it anyway.

    I have only recently started developing wordpress sites (last 6 months) and love the flexibility of the template system and the ability to add my own php snippets.

    I’ve noticed that I add wp_head to all my wordpress themes in the thought it would add important bits required to run the website but i am ever more getting frustrated by the crap placed in it, particularly from plugins.

    For example i frequently use the jquery library in my themes but certain plugins such as the contact form plugin adds it in when it is installed. Not only this but it does it on every page, not even just the ones with forms. This means that people end up download the library twice.

    Another thing which frustrates me is plugins add their own inline css. I am very capable of styling myself and while I understand that there should be css there by default for less tech savvy users there should also be an option to disable it, likewise with javascript.

    i end up looking at my source and feeling ill because of all the extra crap that is placed in the header.

    if anyone could tell me how they deal with this i’d love to know!

    rant over ??

    Dave.

Viewing 6 replies - 1 through 6 (of 6 total)
  • I agree, these things bother me too, especially the CSS issue – for permanent plugin installations, sometimes I’ll dig into the plugin and remove the CSS references and the CSS file, sticking it into my template file and editing it as I see fit from there. This does mean plugin updates are a pain though, I don’t really have a happy medium.

    Adding an option to a plugin that allows the user to manage the inclusion of JavaScript and CSS is super easy. Nevertheless, there’re a lot of plugins that just seem to add their scripts/styles to the header whether they’ll be used on the current page or not.

    If you’ve every tried Yahoo’s YSlow or Google’s Page Speed on the next best site you’ll be amazed at how bad they perform. There’s CSS/JS that’s not used on the current page or JS that could be put into the footer of the page to speed up rendering.

    Since this doesn’t seem to be an issue of WordPress itself but just lazy plugin/theme developers, you should contact the authors of plugins/themes you care about and tell them to fix this issue. Say, in a polite way, that they might add 1) add checkbox on the options page 2) a special custom field that you may add to the pages in question 3) a PHP “define” that you can change in the plugin’s source code.

    While changing the plugin soon becomes a real pain – when updating plugins you’ll have to redo all your changes, if you can still remember them – the custom field or at least an option in the plugin’s settings seem to be a nice way to solve this problem.

    Not only this but it does it on every page, not even just the ones with forms.

    There’s no way for plugins to know which pages to load the library. But, there should be better solutions.

    This means that people end up download the library twice.

    This is because you’re incorrectly loading your JavaScript. See:
    https://codex.www.ads-software.com/Function_Reference/wp_enqueue_script

    Another thing which frustrates me is plugins add their own inline css. I am very capable of styling myself and while I understand that there should be css there by default for less tech savvy users there should also be an option to disable it, likewise with javascript.

    There usually is. See:
    https://codex.www.ads-software.com/Function_Reference/remove_action

    Hi Justin,

    There’s no way for plugins to know which pages to load the library.

    Why not? The plugin can use $post during wp_head and may decide – by e.g. examining the content of the current post – whether it should include the JS/CSS or not.
    In case it isn’t possible or at least tricky for some reason – e.g. plugin called inside an iFrame of the current page – let the user tell the plugin whether it should enqueue a script/style.

    Why not?

    Maybe I should rephrase that:

    There’s not always a way for plugins to know which pages to load the library on. Of course, that’s what options are for.

    Of course, that’s what options are for.

    Sure, so this seems to be – IMO – resolved

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Me moaning about wp_head’ is closed to new replies.