Skip to content

Defer CSS or Disable Option #306

Open

Description

@dshanske

https://wordpress.org/support/topic/disable-css-or-defer-it/

Considering we're looking at reducing this file by default, maybe we shouldn't load it unless the widget is active?

Activity

  1. lhero-org commented on Sep 26, 2026

    @lhero-org

    We hit this on a WordPress multisite running IndieWeb 5.2.0. indieweb.css is about 120 KB raw (28 KB gzipped) and is enqueued on every front-end page, but it only styles rel-me links and h-cards.

    The plugin already runs code at exactly the points where the CSS is needed: Indieweb\Hcard\User::get_rel_me_list() and Indieweb\Hcard\User::hcard(). So it could load on demand with no new option. Register the style on wp_enqueue_scripts instead of enqueueing it, then call wp_enqueue_style( 'indieweb' ) from those two methods.

    With block themes the template renders before wp_head, so the style still lands in the head. With classic themes it gets enqueued late and prints in the footer. A filter could restore always-on loading for sites that style rel-me markup elsewhere.

    We're running this from outside the plugin as a workaround. We dequeue at priority 20 unless indieweb_rel_me or hcard_display_defaults has fired, and re-enqueue if either fires later. Happy to open a PR with unit tests if the approach works for you. It would complement #300, which shrinks the file itself.

  2. pfefferle commented on Sep 26, 2026

    @pfefferle
    Member

    Thanks for the detailed report! The approach looks good to me, get_rel_me_list() and hcard() should cover all the places where the CSS is needed.

    A few notes for the PR:

    • Please register the bw or the default file under the same indieweb handle, so the iw_relme_bw option still works.
    • I would like to have the filter to load the CSS on every page, for themes that use the icons or the h-card markup on their own.
    • The footer loading on classic themes might cause a short unstyled flash. I think this is OK, but I am not 100% sure.

    Happy to review a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions