WordPress.org

Ready to get started?Download WordPress

Forums

Live Blogging
[BUG] JS is enqueued even when not needed (3 posts)

  1. boyska
    Member
    Posted 3 years ago #

    When I am displaying a page with no liveblogs there's no need to load live-blogging.js, as it slows down the page.

    It is possible to do this, but I don't know exactly how to recognize when "it is needed": if we're displaying single posts it's easy, but in home page I don't know how can we discover if "it is needed"

  2. chrisnorthwood
    Member
    Plugin Author

    Posted 3 years ago #

    Yeah, this is definitely something that could be improved - the issue is that when scripts are output (in the header), we don't know if something's going to be output that requires it or not.

    It's not an issue unique to this plugin, but I do accept it could be improved.

  3. boyska
    Member
    Posted 3 years ago #

    actually, there's a way to do so. It's enough to call wp_enqueue inside a the_posts filter. Actually, the best would be to receive an action AFTER the_posts has been called, but I haven't found a way to do this.

    You can see an example here:

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic