Admin bar integration and W3 Total Cache Minify conflict
See original GitHub issueBug Description
After 1.7.0, a user in the forums reported that Site Kit’s admin bar integration and the minify option in the W3 Total Cache plugin conflict causing display issues in the admin bar integration:

In some themes, like WoodMart, CSS display issues also appear when viewing the site while logged in:
Disabling W3 Total Cache’s minify option resolves the issue in both cases (admin bar and broken site CSS). For the theme issue, disabling Site Kit’s admin bar via the following filter also restores the correct display of the site (while W3TC minify is enabled):
add_filter( 'googlesitekit_show_admin_bar_menu', '__return_false', 1000 ); 
Steps to reproduce
- Setup Site Kit and W3 Total Cache with minify option enabled (Performance > General Settings > Minify > Enable) with defaults selected.
 - View a page of the site with stats (to show admin bar integration) while logged in
 - See broken admin bar integration
 - Activate WoodMart theme, see broken display of site additionally.
 
Screenshots
Correct display with default theme (W3TC minify disabled)

Correct display with Woodmart theme (W3TC minify disabled)
Additional Context
- PHP Version: 7.3.16
 - OS: MacOS
 - Browser: Chrome
 - Plugin Version: 1.7.0
 - Device: MacBook Air
 
Related support topic: https://wordpress.org/support/topic/new-update-breaking-my-site-css-on-admin-side/
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- Admin bar should display correctly with Woodmart theme and W3 Total Cache Minify enabled.
 
Implementation Brief
- 
UsingAdmin_Bar/Admin_Bar.php - 
Edit theregistermethod and add a filteradd_filter()with the following:filter hook namew3tc_minify_css_enablecallback function which returnsfalsepriority of10accepted arguments of1
 - 
Add a comment to explain why this filter has been added with@since n.e.x.tto add the version number when it was introduced - 
Using
assets/sass/components/adminbar/_googlesitekit-wp-adminbar.scss,- Update the background image styles of the 
.googlesitekit-wp-adminbar.hover .googlesitekit-wp-adminbar__iconselector along with the other selectors having the same styles to have the SVG background image as a base64 encoded string. 
background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDMiIGhlaWdodD0iNDQiIHZpZXdCb3g9IjAgMCA0MyA0NCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+PGRlZnM+PHBhdGggZD0iTTQyLjUgMThIMjJ2OC41aDExLjhDMzIuNyAzMS45IDI4LjEgMzUgMjIgMzVjLTcuMiAwLTEzLTUuOC0xMy0xM1MxNC44IDkgMjIgOWMzLjEgMCA1LjkgMS4xIDguMSAyLjlsNi40LTYuNEMzMi42IDIuMSAyNy42IDAgMjIgMCA5LjggMCAwIDkuOCAwIDIyczkuOCAyMiAyMiAyMmMxMSAwIDIxLTggMjEtMjIgMC0xLjMtLjItMi43LS41LTR6IiBpZD0iYSIvPjwvZGVmcz48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxtYXNrIGlkPSJiIiBmaWxsPSIjZmZmIj48dXNlIHhsaW5rOmhyZWY9IiNhIi8+PC9tYXNrPjxwYXRoIGZpbGw9IiNGQkJDMDUiIG1hc2s9InVybCgjYikiIGQ9Ik0tMiAzNVY5bDE3IDEzeiIvPjxwYXRoIGZpbGw9IiMzNEE4NTMiIG1hc2s9InVybCgjYikiIGQ9Ik0tMiAzNWwzMC0yMyA3LjkgMUw0Ni0ydjQ4SC0yeiIvPjxwYXRoIGZpbGw9IiM0Mjg1RjQiIG1hc2s9InVybCgjYikiIGQ9Ik00NiA0NkwxNSAyMmwtNC0zTDQ2IDl6Ii8+PHBhdGggZmlsbD0iI0VBNDMzNSIgbWFzaz0idXJsKCNiKSIgZD0iTS0yIDlsMTcgMTMgNy02LjFMNDYgMTJWLTJILTJ6Ii8+PC9nPjwvc3ZnPg=="); - Update the background image styles of the 
 
QA Brief
- Setup Site Kit and W3 Total Cache with minify option enabled (Performance > General Settings > Minify > Enable) with defaults selected.
 - View a page of the site with stats (to show admin bar integration) while logged in
 - The admin bar should not be broken.
 - Additionally, test with the WoodMart theme to see if the admin bar renders correctly.
 
Changelog entry
- Fix admin bar styles conflict with W3 Total Cache Minify functionality.
 
Issue Analytics
- State:
 - Created 3 years ago
 - Comments:11 (3 by maintainers)
 

Top Related StackOverflow Question
@Hazlitte @eugene-manuilov @aaemnnosttv After spending some hours on that, I finally managed to find out the culprit in our CSS which is not playing nicely with
minify. It’s the following line: https://github.com/google/site-kit-wp/blob/develop/assets/sass/components/adminbar/_googlesitekit-wp-adminbar.scss#L82So without minification, the SVG (html decoded) markup is as follows:
but the minified version is as follows:
There is a small diff between those 2 SVGs: Un minified:
Minified:
Basically
minifyis replacing#bby#"and it’s messing the overall CSS output. So in the IB, I’ve suggested webase64encode the SVG to prevent that. I tested it locally and it works fine.QA Update: Pass ✅
Verified: