Lazy load the signup block to speed up page after cache clear

Created on 11 October 2021, about 3 years ago
Updated 26 October 2023, about 1 year ago

Problem/Motivation

After a cache clear the lists need to be retrieved from the Mailchimp API which is a slow operation. This is currently blocking the page from rendering until the API call is complete. In our site with 100+ lists this is taking over 30 seconds.

Steps to reproduce

  • Set up a Mailchimp account with 100+ lists.
  • Enable the Mailchimp Signup module and place the signup form on the front page.
  • Clear the cache.
  • Load the front page

Result: every user that hits the front page in the first 30+ seconds gets a very slow loading page.

Proposed resolution

Render the block using the #lazy_builder which is the standard solution offered by Drupal core for elements that are expensive to render.

User interface changes

The block will only be rendered after all the fast-loading elements in the page is rendered, which might cause some design elements to shift as soon as the block has finished rendering. The page will appear instantly and will not be stuck loading for a very long time for the first users that arrive after a cache clear.

Caveats

For this to work effectively for authenticated users the Big Pipe module should be enabled. For anonymous users, the Sessionless BigPipe module should also be enabled. If these module are not enabled no speedup will be apparent and the page will still load slowly, like before.

Feature request
Status

Closed: works as designed

Version

2.0

Component

Signup Module

Created by

🇧🇬Bulgaria pfrenssen Sofia

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024