WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Filter wp_head() function (5 posts)

  1. newboxters
    Member
    Posted 4 years ago #

    I have 3 plugins (form, chat, poll) that carry a 10 javascripts (ajax) and that makes the site very slow.
    However, only use those plugins in 2 pages of my blog.

    How to configure function wp_head() to load some plugins on some pages only?
    Example: if you only use the chat plugin page id 12, then only that page loads the js, css and all dependent on this plugin, to work.

    Thank you.

  2. stvwlf
    Member
    Posted 4 years ago #

  3. newboxters
    Member
    Posted 4 years ago #

    Thank you for the answer, the article is really good, but left me with a question:
    I need to change the plugin files?
    I can't just add a function to display .js or .css plugin only on certain pages (ids)?

    Well if you have to change files for each plugin is bad, because when it updates the plugin, my amendment wears off, right?

  4. stvwlf
    Member
    Posted 4 years ago #

    because when it updates the plugin, my amendment wears off, right?

    No, the way the article explains to do it, the amendement does NOT wear off when the plugin updates, because you are not modifying the plugin's code, you are activating WP code from outside the plugin that affects the plugin's behavior without being part of the plugin. Unless the plugin developer later changes the name of the files or adds additional files loaded into the head section, you are all set using this method.

  5. newboxters
    Member
    Posted 4 years ago #

    You're right. I just test the method and it worked perfectly.

    Thank you for referring this great article!

Topic Closed

This topic has been closed to new replies.

About this Topic