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:

  1. 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
  2. the account settings form (AccountSettingsForm).
  3. user module's automatic enhancements for #type => 'password' element (to show password strength hints)

Proposed resolution

  1. 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.
  2. 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.

CommentFileSizeAuthor
#1 2368739-1.patch3.4 KBWim Leers
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Status: Active » Needs review
FileSize
3.4 KB
Wim Leers’s picture

Issue tags: +front-end performance
catch’s picture

Status: Needs review » Reviewed & tested by the community

Looks 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.

catch’s picture

Title: Stop user_page_attachments() from attaching an individual CSS file » user_page_attachments() unnecessarily adds an individual CSS file on every page
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Nice 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!

  • webchick committed 090d557 on 8.0.x
    Issue #2368739 by Wim Leers: Fixed user_page_attachments() unnecessarily...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

YesCT’s picture

Issue tags: -front-end performance +frontend performance

changing 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.