Problem/Motivation
When possible, we shouldn't attach CSS or JS files, but asset libraries instead.
user_page_attachments() attaches user.module.css, but that's also part of the user/drupal.user library, so it should attach that instead.
But, there is *nothing* in user.module.css that is generically applicable to all pages, yet it is loaded on all pages. It's only necessary for:
- the permissions configuration UI (for which only
user/drupal.user.permissions is loaded currently, it just happens to be the case that user.module.css is loaded on all pages and hence happens to be correct
- the account settings form (
AccountSettingsForm).
- user module's automatic enhancements for
#type => 'password' element (to show password strength hints)
Proposed resolution
- Split up the CSS file into a
user.admin.css one for point 1, to be compliant with https://www.drupal.org/node/1887922. We'll call this library drupal.user.admin. We then attach that library to AccountSettingsForm. This gets added to the drupal.user.permissions library that already exists.
- And the rest stays as is.
Now there is no more need to load user.module.css on every page! :)
Remaining tasks
None.
User interface changes
None.
API changes
None.
Comments
Comment #1
wim leersComment #2
wim leersComment #3
catchLooks great, I noticed this the other week when reviewing CSS loaded every page, and couldn't see anything in there that would make that necessary but failed to open an issue. RTBC.
Comment #4
catchComment #5
webchickNice catch. Since this is both a bug fix and about markup, which isn't currently locked down, this seems to good to go according to https://www.drupal.org/contribute/core/beta-changes.
Committed and pushed to 8.0.x. Thanks!
Comment #8
yesct commentedchanging to use the more common tag, so the less common one can be deleted, so it does not show up in the auto complete and confuse people.