Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.57k stars 796 forks source link

Boost: Css gen library not defined when premium expires #37680

Open dilirity opened 1 month ago

dilirity commented 1 month ago

[!Note] This is an edge-case, but it can happen.

This was introduced with https://github.com/Automattic/jetpack/pull/37118

If premium expires just as the user is generating cloud css and switches to another tab and then back to the old one, there will be an error about the css gen library not being present:

Image

The only way I reproduced this is locally.

Steps:

Snippet:

<?php

add_action( 'template_redirect', function () {
    exit;
} );
haqadn commented 1 month ago

I see two potential solutions:

  1. Update the message to suggest a page refresh to attempt to fix the issue.
  2. Load the library with JS if it doesn't exist like we previously did. By default, load it with enqueue script, but only load with JS if it's not already enqueued.