-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use of uniqid()
in generated CSS class names breaks ability to cache parsed CSS
#38889
Comments
uniquid()
in generated CSS class names breaks ability to cache parsed CSSuniqid()
in generated CSS class names breaks ability to cache parsed CSS
It makes it hard to test output against static fixtures as well, which is not as important as the issue raised here of course! :) Maybe we can look at this as part of the style engine work. Commented over here as well, but maybe a hash would work better in the interim (?) until we work out a neater solution. |
…ass names. Backports changes from WordPress/gutenberg#38891. See WordPress/gutenberg#38889. Props westonruter, mamaduka. See #55474. Built from https://develop.svn.wordpress.org/trunk@53012 git-svn-id: http://core.svn.wordpress.org/trunk@52601 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…ass names. Backports changes from WordPress/gutenberg#38891. See WordPress/gutenberg#38889. Props westonruter, mamaduka. Merges [53012] to the 5.9 branch. See #55474. git-svn-id: https://develop.svn.wordpress.org/branches/5.9@53013 602fd350-edb4-49c9-b593-d223f7449a82
…ass names. Backports changes from WordPress/gutenberg#38891. See WordPress/gutenberg#38889. Props westonruter, mamaduka. Merges [53012] to the 5.9 branch. See #55474. Built from https://develop.svn.wordpress.org/branches/5.9@53013 git-svn-id: http://core.svn.wordpress.org/branches/5.9@52602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…ass names. Backports changes from WordPress/gutenberg#38891. See WordPress/gutenberg#38889. Props westonruter, mamaduka. See #55474. Built from https://develop.svn.wordpress.org/trunk@53012 git-svn-id: https://core.svn.wordpress.org/trunk@52601 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…ass names. Backports changes from WordPress/gutenberg#38891. See WordPress/gutenberg#38889. Props westonruter, mamaduka. Merges [53012] to the 5.9 branch. See #55474. Built from https://develop.svn.wordpress.org/branches/5.9@53013 git-svn-id: https://core.svn.wordpress.org/branches/5.9@52602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The
Via #38164 |
…ass names. Backports changes from WordPress/gutenberg#38891. See WordPress/gutenberg#38889. Props westonruter, mamaduka. Merges [53012] to the 5.9 branch. See #55474. Built from https://develop.svn.wordpress.org/branches/5.9@53013
…ass names. Backports changes from WordPress/gutenberg#38891. See WordPress/gutenberg#38889. Props westonruter, mamaduka. Merges [53012] to the 5.9 branch. See #55474. Built from https://develop.svn.wordpress.org/branches/5.9@53013 git-svn-id: http://core.svn.wordpress.org/branches/5.9@52602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Description
In a support forum topic for the AMP plugin, a user reported their site slowed down after WordPress 5.9 was released. The cause turned out to be that the AMP plugin's caching of parsed CSS automatically disabled since the CSS on the page contained randomness. This disabling is done to prevent filling up the options table with garbage transient data. I found the cause to be the use of
uniqid()
in functions likewp_render_layout_support_flag()
:https://github.com/WordPress/wordpress-develop/blob/8ec1cb83e346853588606b228b8eaa5921d47782/src/wp-includes/block-supports/layout.php#L162-L176
The use of
uniqid()
actually came up before in the context of the Twenty Seventeen theme. In Core Trac #44883 it was replaced successfully withwp_unique_id()
.The result is that instead of a class name like
wp-container-620e88a091db4
being generated, where620e88a091db4
is random with each page load, a class name likewp-container-5
is generated which is stable across page loads.I created a plugin that replaces
uniqid()
withwp_unique_id()
with successful results: https://gist.github.com/westonruter/71852bfeea22ebd7b570865a95b169d6Related: #35376
Step-by-step reproduction instructions
Add a group block or columns block, view the frontend, and see random class names generated with each page load.
Example
post_content
:Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: