Loading CSS and JS by attaching it to render arrays would solve issues with CSS/JS not loading for cached content, improve performance, alterability, etc.
drupal_add_* will also be remove from Drupal 8 (or will only be available internally), so this will help Privatemsg be more future proof. See #1839338: [meta] Remove drupal_set_*() drupal_add_*() in favour of #attached/response for out-of-band stuff.
Drupal 7 introduced #attached for CSS, JS and some other things so that assets which are needed by a specific element can be properly cached along with its parent element. If you use drupal_add_*() and your code doesn't run (because it's cached), then your CSS won't be added to the page.
Comment | File | Size | Author |
---|---|---|---|
#1 | attach-css-and-js-2034237-1.patch | 5.53 KB | Devin Carlson |
Comments
Comment #1
Devin Carlson CreditAttribution: Devin Carlson commentedA patch to #attach Privatemsg CSS and JS where possible.
Comment #2
ptmkenny CreditAttribution: ptmkenny commentedI applied this patch to my site and confirmed that the CSS is loaded properly. It's working on my local Apache server and also Nginx.
Comment #3
BerdirLooks good, committed and pushed to 7.x-2.x. Small behavior change with the templates, so not backporting.