Follow-up to
#952768: $every_page parameter in drupal_add_library() and drupal_process_attached() undocumented
see comment http://drupal.org/node/952768#comment-3633816 where duellj says:

"I like the much more concise description of $every_page for drupal_add_library(). The description in drupal_add_js and drupal_add_css for $every_page could probably use some cleaning up as well; it took me a while to grok exactly what it does."

CommentFileSizeAuthor
#3 955776-3.patch5.2 KBchrisparsons

Comments

duellj’s picture

Thanks, jhodgdon!

chrisparsons’s picture

Assigned: Unassigned » chrisparsons
chrisparsons’s picture

Assigned: chrisparsons » Unassigned
Status: Active » Needs review
StatusFileSize
new5.2 KB

First attempt... I think I've trimmed the extraneous wording out while still leaving the important information. The only thing that I've trimmed and I'm not sure is extraneous is the wording "is present on every page of the website for users for whom it is present at all", which could be worded much better if it's needed.

Otherwise, the new versions are quite similar to each other:

drupal_add_js:

*   - every_page: Set to TRUE if the JavaScript is present on every page of
*     the website. Defaults to FALSE. It is set to TRUE for JavaScript files
*     that are added via module and theme .info files. All JavaScript files
*     within the same group that have the 'every_page' flag set to TRUE and do
*     not have 'preprocess' set to FALSE are aggregated together. JavaScript
*     without the 'every_page' flag is aggregated into a separate aggregate
*     file.

drupal_add_css:

*   - every_page: Set to TRUE if the JavaScript is present on every page of
*     the website. Defaults to FALSE. It is set to TRUE for JavaScript files
*     that are added via module and theme .info files. All JavaScript files
*     within the same group that have the 'every_page' flag set to TRUE and do
*     not have 'preprocess' set to FALSE are aggregated together. JavaScript
*     without the 'every_page' flag is aggregated into a separate aggregate
*     file.

Patch attached.

chrisparsons’s picture

So I got it right in the patch, but wrong when I pasted it above. Here's the drupal_add_css changed 'every_page':

*   - 'every_page': Set to TRUE if the stylesheet is present on every page of
*     the website. Defaults to FALSE. It is set to TRUE for stylesheets that
*     are added via module and theme .info files. All stylesheets within the
*     same group that have the 'every_page' flag set to TRUE and do not have
*     'preprocess' set to FALSE are aggregated together. Stylesheets without
*     the 'every_page' flag is aggregated into a separate aggregate file.
jhodgdon’s picture

Status: Needs review » Needs work

"All ... that have ... are aggregated together" - I think this is a bit misleading. Aggregation only happens if you have aggregation turned on via the Performance page, right?

"Stylesheets without the 'every_page' flag is aggregated into a separate aggregate file."
is -> are
And is this correct -- these are aggregated too? I wasn't aware of that.

I also noticed this further up on http://api.drupal.org/api/function/drupal_add_js/7 :
"If JavaScript aggregation is enabled, all JavaScript files added with $options['preprocess'] set to TRUE will be merged into one aggregate file. Preprocessed inline JavaScript will not be aggregated into this single file. Externally hosted JavaScripts are never aggregated."
This seems to contradict the 'every_page' section...

I think someone needs to delve into the aggregation code and figure out what is actually happening.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.