Blocks Not Rendering Properly with Tailwind JIT and Big Pipe Enabled for Authenticated Users

Created on 29 September 2024, 4 months ago

Issue Summary

When the Tailwind JIT module is enabled and configured, and Big Pipe is also enabled, certain blocks are missing and are only rendered as Big Pipe placeholder span elements. This issue is replicable for authenticated normal users, but the blocks fail to load correctly.

Steps to Reproduce

  1. Enable and configure the Tailwind JIT module.
  2. Enable the Big Pipe module.
  3. Log in as an authenticated normal user.
  4. Navigate to a page with blocks (e.g., primary local tasks, status messages).
  5. Observe that the blocks are missing, and placeholders are rendered instead.

Expected Behavior

The blocks should be rendered fully and displayed as normal, with no placeholders left unresolved.

Actual Behavior

The blocks are missing, and only Big Pipe placeholders are rendered, such as:

<span data-big-pipe-placeholder-id="callback=Drupal%5Cblock%5CBlockViewBuilder%3A%3AlazyBuilder&amp;args%5B0%5D=stark_breadcrumbs&amp;args%5B1%5D=full&amp;args%5B2%5D&amp;token=AtITWxCJluulEf42Rza7XvakHSXdUEVm8dY24F-1qO8">
</span>

<span data-big-pipe-placeholder-id="callback=Drupal%5CCore%5CRender%5CElement%5CStatusMessages%3A%3ArenderMessages&amp;args%5B0%5D&amp;token=_HAdUpwWmet0TOTe2PSiJuMntExoshbm1kh2wQzzzAA">
</span>

<span data-big-pipe-placeholder-id="callback=Drupal%5Cblock%5CBlockViewBuilder%3A%3AlazyBuilder&amp;args%5B0%5D=stark_secondary_local_tasks&amp;args%5B1%5D=full&amp;args%5B2%5D&amp;token=IlXJ3VpRxHExqXET_837fLOnN1qVT_EKb3gFXPgBEsg">
</span>

Affected Components

  • Tailwind JIT Module
  • Big Pipe Module
  • Block rendering for authenticated users

Possible Cause

There might be a conflict between how the Tailwind JIT module processes the CSS and the way Big Pipe attempts to lazily load certain blocks, causing the block to remain unresolved.

Environment
Drupal Version: 10.3.5
Tailwind JIT Version: 1.1.1

🐛 Bug report
Status

Active

Version

1.1

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @cyrusliew
  • 🇦🇹Austria hudri Austria

    Thanks for your report, I'll take a look at it.

    On a side note, by architecture using BipPipe with Tailwind JIT has some limitations:

    If you've got a page like

    <div class="outer_container">
      <span class="bigpiple_placeholder"> <!-- block will be injected here --> </span>
    </div>
    

    and CSS with child styles like

    .outer_container .inner_style_from_a_bigpipe_replaced_block { ... }
    

    then Tailwind JIT can not detect this inner style style due the structure of the source code. (Nevertheless the blocks need to be replaced properly, I'll check this.)

  • 🇦🇹Austria hudri Austria

    @cyrusliew

    Could you please test if the MR / patch fixes your problems?

    https://git.drupalcode.org/project/tailwind_jit/-/merge_requests/8.patch

  • @hudri Thank you for the patch. After applying it, the blocks are rendering fine, but there is another issue that has surfaced. The styles targeting CSS classes within these affected blocks are not being applied correctly. It seems that while the blocks are rendered, the Tailwind CSS classes aren't functioning as expected in these particular instances. This issue persists only on blocks impacted by the Big Pipe module.

    Here are a couple of scenarios to illustrate the problem:

    1. Styling the affected block with its class in the CSS file does not work:
    - Targeting the block using its ID (e.g., #block-trydrupal-primary-local-tasks) works.
    - However, targeting the block by its class (e.g., .block-local-tasks-block) does not work.

    2. Styling the children inside the affected block by adding utility classes directly to its template does not work:
    - Example: <a href="/node/2/edit" class="button inline-block w-[300px] text-white" data-drupal-link-system-path="node/2/edit">Edit</a>
    - In this case, only the button class works, while other utility classes (like inline-block, w-[300px], and text-white) are not applied.

  • 🇦🇹Austria hudri Austria

    This is a known issue, and it is not possible to fix this in a meaningful way. Basically the architecture and philosophy of Tailwind and BigPipe are almost exact opposites:

    • Tailwind JIT tries to generate a purged, minimized inline CSS on the server as early as possible for a perfectly optimized CSS with an ideal critical CSS rendering path.
    • BigPipe renders blocks very late at page end with chunked streaming and injects them with client side JavaScript for a better perceived loading performance

    I recommend to disable BigPipe completely. In my experience, the real word performance gain of BigPipe is neglectable. If you have blocks that are very slow, you could load them with "real" async Ajax requests, which a) work with Tailwind JIT and b) actually do deliver a real world performance gain.

  • @hudri Thank you for the clarification. I understand the conflict between Tailwind JIT and Big Pipe. I’ll explore disabling Big Pipe as suggested, as well as using async Ajax requests for slower blocks.

    Appreciate your advice and quick response!

  • 🇦🇹Austria hudri Austria

    Fixed in version 1.1.2

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024