wp-media / wp-rocket

Performance optimization plugin for WordPress
https://wp-rocket.me
GNU General Public License v2.0
701 stars 218 forks source link

Clear Used CSS after a Theme update #6217

Closed alfonso100 closed 4 months ago

alfonso100 commented 1 year ago

Is your feature request related to a problem? Please describe. When a theme is updated by the user we don't clear the used CSS

Describe the solution you'd like Since a theme update might contain modified/new CSS, we should clear the used css

Describe alternatives you've considered Hook a usedcss cleanup here https://github.com/wp-media/wp-rocket/blob/89fcfb1fa5acd8c806edc9ea8aeb058f2b5131e7/inc/common/purge.php#L577-L603

Can be achieved with a helper plugin: https://github.com/wp-media/wp-rocket-snippets/blob/main/wp-rocket/wp-rocket-clear-usedcss-after-theme-update.php

Additional context ticket: https://secure.helpscout.net/conversation/2387301118/447830?folderId=2683093 slack: https://wp-media.slack.com/archives/C43T1AYMQ/p1697054621682859

tatof commented 1 year ago

Extra feature question: Does the "clear used CSS" get triggered on a automatic theme update?

worldwildweb commented 1 year ago

Would be nice to clear the Used CSS after a plugin update also slack: https://wp-media.slack.com/archives/C08N8J6VC/p1697530071237479

webtrainingwheels commented 1 year ago

I'd personally prefer it to be manually triggered, but maybe we can show a notice to suggest it if needed (like we do with cache clearing after plugin updates). Regenerating the CSS is too time-consuming of a process and should only be done when absolutely necessary, IMO.

tatof commented 1 year ago

I'm running one theme with updates on multiple websites 40+ and I would like to clear the Used CSS after I push a necessary theme update. Now I have to login to every client and press the clear button...

If there is a hook to trigger it from within my theme its also a solution :)

piotrbak commented 1 year ago

@DahmaniAdame What do you think about this? Automatically clearing Used CSS after each theme/plugin update seems to be a huge waste of resources.

tatof commented 1 year ago

@piotrbak CSS is one of the most important parts of a theme. Theme updates should trigger a regenerate of cache & used CSS.

Tor example: The theme developer fixed html of a button and needed to alter the CSS to maintain the styling. Theme update rolls out, Cache is deleted but Used CSS is not. Then you have a button with new html but broken styling. Don't think that's what you want.

DahmaniAdame commented 1 year ago

@piotrbak the risk is that if the update has a front-end change. That would result in a broken element.

A notification about the change to the customer with them taking action if necessary will do.

Just like with do when adding/removing a plugin. We prompt a message to ask the customer clear cache if they know there is a change on the frontend. That will reduce the risk of something breaking.

@tatof

CSS is one of the most important parts of a theme.

It's not always the case.

But I agree that we need to provide a clearer way to communicate the risk and help the customer take action.

piotrbak commented 1 year ago

@DahmaniAdame So, when the currently used theme is updated, we should display a notice similar to this one? image

piotrbak commented 4 months ago

We did not have enough feedback from customers related to this issue. We might reopen this in the future.

For now the solution is to use the helper plugin. Theme's updates should not cause the changes in the UI.