You are here

README.txt in Advanced CSS/JS Aggregation 8.2

Same filename and directory in other branches
  1. 6 README.txt
  2. 7 README.txt
----------------------------------
ADVANCED CSS/JS AGGREGATION MODULE
----------------------------------


CONTENTS OF THIS FILE
---------------------

 - Features & benefits
 - Configuration
 - JSMin PHP Extension
 - JavaScript Bookmarklet
 - Technical Details & Hooks
 - How to get a high PageSpeed score
 - nginx Configuration
 - Troubleshooting


FEATURES & BENEFITS
-------------------

**Advanced CSS/JS Aggregation core features**

 - On demand generation of CSS/JS Aggregates. If the file doesn't exist it will
   be generated on demand.
 - Stampede protection for CSS and JS aggregation. Uses locking so multiple
   requests for the same thing will result in only one thread doing the work.
 - Fully cached CSS/JS assets allow for zero file I/O if the Aggregated file
   already exists. Results in better page generation performance.
 - Smarter aggregate deletion. CSS/JS aggregates only get removed from the
   folder if they have not been used/accessed in the last 30 days.
 - Smarter cache flushing. Scans all CSS/JS files that have been added to any
   aggregate; if that file has changed then flush the correct caches so the
   changes go out. The new name ensures changes go out when using CDNs.
 - Url query string to turn off aggregation for that request. ?advagg=0 will
   turn off file aggregation if the user has the "bypass advanced aggregation"
   permission. ?advagg=-1 will completely bypass all of Advanced CSS/JS
   Aggregations modules and submodules. ?advagg=1 will enable Advanced CSS/JS
   Aggregation if it is currently disabled.
 - Button on the admin page for dropping a cookie that will turn off file
   aggregation. Useful for theme development.
 - Gzip support. All aggregated files can be pre-compressed into a .gz file and
   served from Apache. This is faster then gzipping the file on each request.

**Included submodules**

 - advagg_bundler:
   Smartly groups files together - given a target number of CSS/JS aggregates,
   this will try very hard to meet that goal.
 - advagg_cdn:
   Load CSS or JavaScript libraries from a public CDN; currently only supports
   jQuery and jQuery UI with either Google's or Microsoft's CDN.
 - advagg_css_minify:
   Minify the compiled CSS files using a 3rd party minifier; currently
   supports YUI (included).
 - minify:
   Compress the compiled JavaScript files using a 3rd party minifier;
   built in support for a number of minifiers.
 - advagg_mod:
   Includes additional tweaks that may not work for all sites:
   - Force preprocessing for all CSS/JS.
   - Move all JS to footer.
   - Add defer tag to all JS.
   - Inline all CSS/JS for given paths.
   - Use a shared directory for a unified multisite.
 - advagg_validator:
   Validate all CSS files using jigsaw.w3.org. Check all CSS files with CSSLint.
   Check all JS files with JSHint.


CONFIGURATION
-------------

Settings page is located at:
`admin/config/development/performance/advagg`

**Global Options**

 - Enable Advanced Aggregation: Check this to start using this module. You can
   also quickly disable the module here. For testing purposes, this has the same
   effect as placing ?advagg=-1 in the URL. Disabled by default.
 - Create .gz files: Check this by default as it will improve your performance.
   For every Aggregated file generated, this will create a gzip version of file
   and then only serve it out if the browser accepts gzip files compression.
   Enabled by default.
 - Use Cores Grouping Logic: Leave this checkbox enabled until you are ready to
   begin exploring the AdvAgg Bundler sub-module which overrides Core's
   functionality. This groups files just like Core does so should just work.
   Enabled by default. You will also have to disable this checkbox if you wish
   to enable some of the CSS Options below on this settings page.
 - AdvAgg Cache Settings: As a reference, core takes about 25 ms to run.
   Development will scan all files for a change on every page load. Normal is
   fine for all use cases. Aggressive should be fine in almost all use cases;
   if your inline css/js changes based off of a variable then the aggressive
   cache hit ratio will be low; if that is the case consider using
   Drupal.settings for a better cache hit ratio.

**CSS Options & JS Options**

 - Combine CSS files by using media queries: "Use cores grouping logic" needs to
   be unchecked in order for this to work. Also noted is that due to an issue
   with IE9, compatibility mode is forced off if this is enabled by adding this
   tag in the html head:

       <!--[if IE]>
       <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
       <![endif]-->

   Disabled by default.
 - Prevent more than 4095 CSS selectors in an aggregated CSS file: Internet
   Explorer before version 10; IE9, IE8, IE7, & IE6 all have 4095 as the limit
   for the maximum number of css selectors that can be in a file. Enabling this
   will prevent CSS aggregates from being created that exceed this limit. For
   more information see
   http://blogs.msdn.com/b/ieinternals/archive/2011/05/14/10164546.aspx Disabled
   by default.
 - Fix improperly set type (CSS/JS): If type is external but does not start with
   http, https, or // change it to be type file. If type is file but it starts
   with http, https, or // change type to be external.

**Information page**

located at `admin/config/development/performance/advagg/info`. This page
provides debugging information. There are no configuration options here.
 - Hook Theme Info: Displays the process_html order. Used for debugging.
 - CSS files: Displays how often a file has changed.
 - JS files: Displays how often a file has changed.
 - Modules implementing AdvAgg CSS/JS hooks: Lets you know what modules are
   using advagg.
 - AdvAgg CSS/JS hooks implemented by modules: Lets you know what advagg hooks
   are in use.
 - Hooks And Variables Used In Hash: Show what is used to calculate the 3rd hash
   of an aggregates filename.
 - Get detailed info about an aggregate file: Look up detailed array about any
   CSS or JS file listed.

**Operations page**

located at `admin/config/development/performance/advagg/operations`. This is a
collection of commands to control the cache and to manage testing of this
module. In general this page is useful when troubleshooting some aggregation
issues. For normal operations, you do not need to do anything on this page below
the Smart Cache Flush. There are no configuration options here.
 - Smart Cache Flush
   - Flush AdvAgg Cache: Scan all files referenced in aggregated files. If
     any of them have changed, increment the counters containing that file and
     rebuild the bundle.

 - Aggregation Bypass Cookie
    - Toggle The "aggregation bypass cookie" For This Browser: This will set or
      remove a cookie that disables aggregation for the remainder of the browser
      session. It acts almost the same as adding ?advagg=0 to every URL.

 - Cron Maintenance Tasks
   - Remove All Stale Files: Scan all files in the advagg_css/js directories and
     remove the ones that have not been accessed in the last 30 days.
   - Clear Missing Files From the Database: Scan for missing files and remove
     the associated entries in the database.
   - Delete Unused Aggregates from Database: Delete aggregates that have not
     been accessed in the last 6 weeks.
   - Delete orphaned/expired advagg locks from the semaphore database table.

 - Drastic Measures
   - Clear All Caches: Remove all data stored in the advagg cache bins.
   - Remove All Generated Files. Remove all files in the advagg_css/js
     directories.
   - Increment Global Counter: Force the creation of all new aggregates by
     incrementing a global counter.

**Hidden Settings**

The following settings are not configurable from the admin UI and must be set in
settings.php. In general they are settings that should not be changed. The
current defaults are shown.

    // Display a message that the bypass cookie is set.
    $conf['show_bypass_cookie_message'] = TRUE;

    // Skip the 404 check on status page.
    $conf['advagg_skip_404_check'] = FALSE;

    // Run advagg_url_inbound_alter().
    $conf['advagg_url_inbound_alter'] = TRUE;

    // Pregenerate aggregate files. If disable the browser requesting the file
    // will cause the generation to happen. If advagg 404 handling is broken
    // then setting this to false will break your site in bad ways.
    $conf['advagg_pregenerate_aggregate_files'] = TRUE;

    // Value for the compression ratio test.
    $conf['advagg_js_compress_max_ratio'] = 0.9;

    // Value for the compression ratio test.
    $conf['advagg_js_compress_ratio'] = 0.1;

    // Skip far future check on status page.
    $conf['advagg_skip_far_future_check'] = FALSE;

    // Skip preprocess and enabled checks.
    $conf['skip_enabled_preprocess_check'] = FALSE;

    // Default root dir for the advagg files; see advagg_get_root_files_dir().
    $conf['root_dir_prefix'] = 'public://';

JSMIN PHP EXTENSION
-------------------

The AdvAgg JS Minify module can take advantage of jsmin.c. JavaScript parsing
and minimizing will be done in C instead of PHP dramatically speeding up the
process. JsMin C extension can be found at https://github.com/sqmk/pecl-jsmin.


JAVASCRIPT BOOKMARKLET
----------------------

You can use this JS code as a bookmarklet for toggling the AdvAgg URL parameter.
See http://en.wikipedia.org/wiki/Bookmarklet for more details.

    javascript:(function(){var loc = document.location.href,qs = document.location.search,regex_off = /\&?advagg=-1/,goto = loc;if(qs.match(regex_off)) {goto = loc.replace(regex_off, '');} else {qs = qs ? qs + '&advagg=-1' : '?advagg=-1';goto = document.location.pathname + qs;}window.location = goto;})();


TECHNICAL DETAILS & HOOKS
-------------------------

**Technical Details**

 - Files are generated by this pattern:

       css__[BASE64_HASH]__[BASE64_HASH]__[BASE64_HASH].css

   The first base64 hash value tells us what files are included in the
   aggregate. Changing what files get included will change this value.

   The second base64 hash value is used as a sort of version control; it changes
   if any of the base files contents have changed. Changing a base file's content
   (like drupal.js) will change this value.

   The third base64 hash value records what settings were used when generating
   the aggregate. Changing a setting that affects how aggregates get built
   (like toggling "Create .gz files") will change this value.

 - Aggressive Cache Setting: This will fully cache the rendered html generated
   by AdvAgg. The cache ID is set by this code:

       $hooks_hash = advagg_get_current_hooks_hash();
       $css_cache_id_full = 'advagg:css:full:' . $hooks_hash . ':' . drupal_hash_base64(serialize($full_css));

       $hooks_hash = advagg_get_current_hooks_hash();
       $js_cache_id_full = 'advagg:js:full:' . $hooks_hash . ':' . drupal_hash_base64(serialize($js_scope_array));

   The second and final hash value in this cache id is the css/js_hash value.
   This takes the input from drupal_add_css/js() and creates a hash value from
   it. If a different file is added and/or inline code changed, this hash value
   will be different.

   The first hash value will take the current_hooks_hash value which is the
   third base64 hash value listed above in this section (Technical Details) as
   the first part of the hash. This means that if any value is changed in this
   nested array a different cache id will be used. You can see the contents of
   this nested array by going to
   `admin/config/development/performance/advagg/info` under
   "Hooks And Variables Used In Hash". An example of this being properly used is
   if you enable the core locale module the language key will appear in the
   array. This is needed because the locale_css_alter and locale_js_alter
   functions both use the global $language variable in determining what css or
   js files need to be altered. To add in your own context you can use
   hook_advagg_current_hooks_hash_array_alter to do so. Be careful when doing so
   as including something like the user id will make every user have a different
   set of aggregate files.

**Hooks**

Modify file contents:
 - advagg_css_contents_alter. Modify the data of each file before it
   gets glued together into the bigger aggregate. Useful for minification.
 - advagg_js_contents_alter. Modify the data of each file before it
   gets glued together into the bigger aggregate. Useful for minification.

Modify file names and aggregate bundles:
 - advagg_current_hooks_hash_array_alter. Add in your own settings and hooks
   allowing one to modify the 3rd base64 hash in a filename.

Others:
 - advagg_hooks_implemented_alter. Tell advagg about other hooks related to
   advagg.
 - advagg_get_root_files_dir_alter. Allow other modules to alter css and js
   paths.
 - advagg_modify_css_pre_render_alter. Allow other modules to modify $children
   & $elements before they are rendered.
 - advagg_modify_js_pre_render_alter. Allow other modules to modify $children
   & $elements before they are rendered.
 - advagg_changed_files. Let other modules know about the changed files.
 - advagg_removed_aggregates. Let other modules know about removed aggregates.
 - advagg_scan_for_changes. Let other modules see if files related to this file
   has changed. Useful for detecting changes to referenced images in css.
 - advagg_scan_file_alter. Let other modules modify information about
   the base CSS/JS files.
 - advagg_context_alter. Allow other modules to swap important contextual
   information on generation.
 - advagg_bundler_analysis. If the bundler module is installed allow for other
   modules to change the bundler analysis.


HOW TO GET A HIGH PAGESPEED SCORE
---------------------------------

Go to `admin/config/development/performance/advagg`
 - uncheck "Use cores grouping logic"
 - check "Combine CSS files by using media queries"

Install AdvAgg Modifier if not enabled and go to
`admin/config/development/performance/advagg/mod`
 - Under "Move JS to the footer" Select "All"
 - set "Enable preprocess on all JS/CSS"
 - set "Move JavaScript added by drupal_add_html_head() into drupal_add_js()"
 - set "Move CSS added by drupal_add_html_head() into drupal_add_css()"
 - Enable every checkbox under "Optimize JavaScript/CSS Ordering"

Install AdvAgg Minify Javascript if not enabled and go to
`admin/config/development/performance/advagg/js-minify`
 - Select JSMin if available; otherwise select JSMin+

**Other things to consider**

On the `admin/config/development/performance/advagg/mod` page there is the
setting "Remove unused JavaScript tags if possible". This is a backport of D8
where it will not add any JS to the page if it is not being used.
https://drupal.org/node/1279226

The AdvAgg Bundler module on the
`admin/config/development/performance/advagg/bundler` page. The bundler provides
intelligent bundling of CSS and JS files by grouping files that belong together.
This does what core tried to do; group CSS & JS files together that get used
together. Using this will make your pagespeed score go down as there will be
more css/js files to download but if different css/js files are used on
different pages of your site this will be a net win as a new full aggregate will
not have to be downloaded, instead a smaller aggregate can be downloaded,
ideally with only the css/js that is different on that page. You can select how
many bundles to create and the bundler will do it's best to meet that goal; if
using browser css/js conditionals (js browser conditionals backported from D8
https://drupal.org/node/865536) then the bundler might not meet your set value.

File

README.txt
View source
  1. ----------------------------------
  2. ADVANCED CSS/JS AGGREGATION MODULE
  3. ----------------------------------
  4. CONTENTS OF THIS FILE
  5. ---------------------
  6. - Features & benefits
  7. - Configuration
  8. - JSMin PHP Extension
  9. - JavaScript Bookmarklet
  10. - Technical Details & Hooks
  11. - How to get a high PageSpeed score
  12. - nginx Configuration
  13. - Troubleshooting
  14. FEATURES & BENEFITS
  15. -------------------
  16. **Advanced CSS/JS Aggregation core features**
  17. - On demand generation of CSS/JS Aggregates. If the file doesn't exist it will
  18. be generated on demand.
  19. - Stampede protection for CSS and JS aggregation. Uses locking so multiple
  20. requests for the same thing will result in only one thread doing the work.
  21. - Fully cached CSS/JS assets allow for zero file I/O if the Aggregated file
  22. already exists. Results in better page generation performance.
  23. - Smarter aggregate deletion. CSS/JS aggregates only get removed from the
  24. folder if they have not been used/accessed in the last 30 days.
  25. - Smarter cache flushing. Scans all CSS/JS files that have been added to any
  26. aggregate; if that file has changed then flush the correct caches so the
  27. changes go out. The new name ensures changes go out when using CDNs.
  28. - Url query string to turn off aggregation for that request. ?advagg=0 will
  29. turn off file aggregation if the user has the "bypass advanced aggregation"
  30. permission. ?advagg=-1 will completely bypass all of Advanced CSS/JS
  31. Aggregations modules and submodules. ?advagg=1 will enable Advanced CSS/JS
  32. Aggregation if it is currently disabled.
  33. - Button on the admin page for dropping a cookie that will turn off file
  34. aggregation. Useful for theme development.
  35. - Gzip support. All aggregated files can be pre-compressed into a .gz file and
  36. served from Apache. This is faster then gzipping the file on each request.
  37. **Included submodules**
  38. - advagg_bundler:
  39. Smartly groups files together - given a target number of CSS/JS aggregates,
  40. this will try very hard to meet that goal.
  41. - advagg_cdn:
  42. Load CSS or JavaScript libraries from a public CDN; currently only supports
  43. jQuery and jQuery UI with either Google's or Microsoft's CDN.
  44. - advagg_css_minify:
  45. Minify the compiled CSS files using a 3rd party minifier; currently
  46. supports YUI (included).
  47. - minify:
  48. Compress the compiled JavaScript files using a 3rd party minifier;
  49. built in support for a number of minifiers.
  50. - advagg_mod:
  51. Includes additional tweaks that may not work for all sites:
  52. - Force preprocessing for all CSS/JS.
  53. - Move all JS to footer.
  54. - Add defer tag to all JS.
  55. - Inline all CSS/JS for given paths.
  56. - Use a shared directory for a unified multisite.
  57. - advagg_validator:
  58. Validate all CSS files using jigsaw.w3.org. Check all CSS files with CSSLint.
  59. Check all JS files with JSHint.
  60. CONFIGURATION
  61. -------------
  62. Settings page is located at:
  63. `admin/config/development/performance/advagg`
  64. **Global Options**
  65. - Enable Advanced Aggregation: Check this to start using this module. You can
  66. also quickly disable the module here. For testing purposes, this has the same
  67. effect as placing ?advagg=-1 in the URL. Disabled by default.
  68. - Create .gz files: Check this by default as it will improve your performance.
  69. For every Aggregated file generated, this will create a gzip version of file
  70. and then only serve it out if the browser accepts gzip files compression.
  71. Enabled by default.
  72. - Use Cores Grouping Logic: Leave this checkbox enabled until you are ready to
  73. begin exploring the AdvAgg Bundler sub-module which overrides Core's
  74. functionality. This groups files just like Core does so should just work.
  75. Enabled by default. You will also have to disable this checkbox if you wish
  76. to enable some of the CSS Options below on this settings page.
  77. - AdvAgg Cache Settings: As a reference, core takes about 25 ms to run.
  78. Development will scan all files for a change on every page load. Normal is
  79. fine for all use cases. Aggressive should be fine in almost all use cases;
  80. if your inline css/js changes based off of a variable then the aggressive
  81. cache hit ratio will be low; if that is the case consider using
  82. Drupal.settings for a better cache hit ratio.
  83. **CSS Options & JS Options**
  84. - Combine CSS files by using media queries: "Use cores grouping logic" needs to
  85. be unchecked in order for this to work. Also noted is that due to an issue
  86. with IE9, compatibility mode is forced off if this is enabled by adding this
  87. tag in the html head:
  88. Disabled by default.
  89. - Prevent more than 4095 CSS selectors in an aggregated CSS file: Internet
  90. Explorer before version 10; IE9, IE8, IE7, & IE6 all have 4095 as the limit
  91. for the maximum number of css selectors that can be in a file. Enabling this
  92. will prevent CSS aggregates from being created that exceed this limit. For
  93. more information see
  94. http://blogs.msdn.com/b/ieinternals/archive/2011/05/14/10164546.aspx Disabled
  95. by default.
  96. - Fix improperly set type (CSS/JS): If type is external but does not start with
  97. http, https, or // change it to be type file. If type is file but it starts
  98. with http, https, or // change type to be external.
  99. **Information page**
  100. located at `admin/config/development/performance/advagg/info`. This page
  101. provides debugging information. There are no configuration options here.
  102. - Hook Theme Info: Displays the process_html order. Used for debugging.
  103. - CSS files: Displays how often a file has changed.
  104. - JS files: Displays how often a file has changed.
  105. - Modules implementing AdvAgg CSS/JS hooks: Lets you know what modules are
  106. using advagg.
  107. - AdvAgg CSS/JS hooks implemented by modules: Lets you know what advagg hooks
  108. are in use.
  109. - Hooks And Variables Used In Hash: Show what is used to calculate the 3rd hash
  110. of an aggregates filename.
  111. - Get detailed info about an aggregate file: Look up detailed array about any
  112. CSS or JS file listed.
  113. **Operations page**
  114. located at `admin/config/development/performance/advagg/operations`. This is a
  115. collection of commands to control the cache and to manage testing of this
  116. module. In general this page is useful when troubleshooting some aggregation
  117. issues. For normal operations, you do not need to do anything on this page below
  118. the Smart Cache Flush. There are no configuration options here.
  119. - Smart Cache Flush
  120. - Flush AdvAgg Cache: Scan all files referenced in aggregated files. If
  121. any of them have changed, increment the counters containing that file and
  122. rebuild the bundle.
  123. - Aggregation Bypass Cookie
  124. - Toggle The "aggregation bypass cookie" For This Browser: This will set or
  125. remove a cookie that disables aggregation for the remainder of the browser
  126. session. It acts almost the same as adding ?advagg=0 to every URL.
  127. - Cron Maintenance Tasks
  128. - Remove All Stale Files: Scan all files in the advagg_css/js directories and
  129. remove the ones that have not been accessed in the last 30 days.
  130. - Clear Missing Files From the Database: Scan for missing files and remove
  131. the associated entries in the database.
  132. - Delete Unused Aggregates from Database: Delete aggregates that have not
  133. been accessed in the last 6 weeks.
  134. - Delete orphaned/expired advagg locks from the semaphore database table.
  135. - Drastic Measures
  136. - Clear All Caches: Remove all data stored in the advagg cache bins.
  137. - Remove All Generated Files. Remove all files in the advagg_css/js
  138. directories.
  139. - Increment Global Counter: Force the creation of all new aggregates by
  140. incrementing a global counter.
  141. **Hidden Settings**
  142. The following settings are not configurable from the admin UI and must be set in
  143. settings.php. In general they are settings that should not be changed. The
  144. current defaults are shown.
  145. // Display a message that the bypass cookie is set.
  146. $conf['show_bypass_cookie_message'] = TRUE;
  147. // Skip the 404 check on status page.
  148. $conf['advagg_skip_404_check'] = FALSE;
  149. // Run advagg_url_inbound_alter().
  150. $conf['advagg_url_inbound_alter'] = TRUE;
  151. // Pregenerate aggregate files. If disable the browser requesting the file
  152. // will cause the generation to happen. If advagg 404 handling is broken
  153. // then setting this to false will break your site in bad ways.
  154. $conf['advagg_pregenerate_aggregate_files'] = TRUE;
  155. // Value for the compression ratio test.
  156. $conf['advagg_js_compress_max_ratio'] = 0.9;
  157. // Value for the compression ratio test.
  158. $conf['advagg_js_compress_ratio'] = 0.1;
  159. // Skip far future check on status page.
  160. $conf['advagg_skip_far_future_check'] = FALSE;
  161. // Skip preprocess and enabled checks.
  162. $conf['skip_enabled_preprocess_check'] = FALSE;
  163. // Default root dir for the advagg files; see advagg_get_root_files_dir().
  164. $conf['root_dir_prefix'] = 'public://';
  165. JSMIN PHP EXTENSION
  166. -------------------
  167. The AdvAgg JS Minify module can take advantage of jsmin.c. JavaScript parsing
  168. and minimizing will be done in C instead of PHP dramatically speeding up the
  169. process. JsMin C extension can be found at https://github.com/sqmk/pecl-jsmin.
  170. JAVASCRIPT BOOKMARKLET
  171. ----------------------
  172. You can use this JS code as a bookmarklet for toggling the AdvAgg URL parameter.
  173. See http://en.wikipedia.org/wiki/Bookmarklet for more details.
  174. javascript:(function(){var loc = document.location.href,qs = document.location.search,regex_off = /\&?advagg=-1/,goto = loc;if(qs.match(regex_off)) {goto = loc.replace(regex_off, '');} else {qs = qs ? qs + '&advagg=-1' : '?advagg=-1';goto = document.location.pathname + qs;}window.location = goto;})();
  175. TECHNICAL DETAILS & HOOKS
  176. -------------------------
  177. **Technical Details**
  178. - Files are generated by this pattern:
  179. css__[BASE64_HASH]__[BASE64_HASH]__[BASE64_HASH].css
  180. The first base64 hash value tells us what files are included in the
  181. aggregate. Changing what files get included will change this value.
  182. The second base64 hash value is used as a sort of version control; it changes
  183. if any of the base files contents have changed. Changing a base file's content
  184. (like drupal.js) will change this value.
  185. The third base64 hash value records what settings were used when generating
  186. the aggregate. Changing a setting that affects how aggregates get built
  187. (like toggling "Create .gz files") will change this value.
  188. - Aggressive Cache Setting: This will fully cache the rendered html generated
  189. by AdvAgg. The cache ID is set by this code:
  190. $hooks_hash = advagg_get_current_hooks_hash();
  191. $css_cache_id_full = 'advagg:css:full:' . $hooks_hash . ':' . drupal_hash_base64(serialize($full_css));
  192. $hooks_hash = advagg_get_current_hooks_hash();
  193. $js_cache_id_full = 'advagg:js:full:' . $hooks_hash . ':' . drupal_hash_base64(serialize($js_scope_array));
  194. The second and final hash value in this cache id is the css/js_hash value.
  195. This takes the input from drupal_add_css/js() and creates a hash value from
  196. it. If a different file is added and/or inline code changed, this hash value
  197. will be different.
  198. The first hash value will take the current_hooks_hash value which is the
  199. third base64 hash value listed above in this section (Technical Details) as
  200. the first part of the hash. This means that if any value is changed in this
  201. nested array a different cache id will be used. You can see the contents of
  202. this nested array by going to
  203. `admin/config/development/performance/advagg/info` under
  204. "Hooks And Variables Used In Hash". An example of this being properly used is
  205. if you enable the core locale module the language key will appear in the
  206. array. This is needed because the locale_css_alter and locale_js_alter
  207. functions both use the global $language variable in determining what css or
  208. js files need to be altered. To add in your own context you can use
  209. hook_advagg_current_hooks_hash_array_alter to do so. Be careful when doing so
  210. as including something like the user id will make every user have a different
  211. set of aggregate files.
  212. **Hooks**
  213. Modify file contents:
  214. - advagg_css_contents_alter. Modify the data of each file before it
  215. gets glued together into the bigger aggregate. Useful for minification.
  216. - advagg_js_contents_alter. Modify the data of each file before it
  217. gets glued together into the bigger aggregate. Useful for minification.
  218. Modify file names and aggregate bundles:
  219. - advagg_current_hooks_hash_array_alter. Add in your own settings and hooks
  220. allowing one to modify the 3rd base64 hash in a filename.
  221. Others:
  222. - advagg_hooks_implemented_alter. Tell advagg about other hooks related to
  223. advagg.
  224. - advagg_get_root_files_dir_alter. Allow other modules to alter css and js
  225. paths.
  226. - advagg_modify_css_pre_render_alter. Allow other modules to modify $children
  227. & $elements before they are rendered.
  228. - advagg_modify_js_pre_render_alter. Allow other modules to modify $children
  229. & $elements before they are rendered.
  230. - advagg_changed_files. Let other modules know about the changed files.
  231. - advagg_removed_aggregates. Let other modules know about removed aggregates.
  232. - advagg_scan_for_changes. Let other modules see if files related to this file
  233. has changed. Useful for detecting changes to referenced images in css.
  234. - advagg_scan_file_alter. Let other modules modify information about
  235. the base CSS/JS files.
  236. - advagg_context_alter. Allow other modules to swap important contextual
  237. information on generation.
  238. - advagg_bundler_analysis. If the bundler module is installed allow for other
  239. modules to change the bundler analysis.
  240. HOW TO GET A HIGH PAGESPEED SCORE
  241. ---------------------------------
  242. Go to `admin/config/development/performance/advagg`
  243. - uncheck "Use cores grouping logic"
  244. - check "Combine CSS files by using media queries"
  245. Install AdvAgg Modifier if not enabled and go to
  246. `admin/config/development/performance/advagg/mod`
  247. - Under "Move JS to the footer" Select "All"
  248. - set "Enable preprocess on all JS/CSS"
  249. - set "Move JavaScript added by drupal_add_html_head() into drupal_add_js()"
  250. - set "Move CSS added by drupal_add_html_head() into drupal_add_css()"
  251. - Enable every checkbox under "Optimize JavaScript/CSS Ordering"
  252. Install AdvAgg Minify Javascript if not enabled and go to
  253. `admin/config/development/performance/advagg/js-minify`
  254. - Select JSMin if available; otherwise select JSMin+
  255. **Other things to consider**
  256. On the `admin/config/development/performance/advagg/mod` page there is the
  257. setting "Remove unused JavaScript tags if possible". This is a backport of D8
  258. where it will not add any JS to the page if it is not being used.
  259. https://drupal.org/node/1279226
  260. The AdvAgg Bundler module on the
  261. `admin/config/development/performance/advagg/bundler` page. The bundler provides
  262. intelligent bundling of CSS and JS files by grouping files that belong together.
  263. This does what core tried to do; group CSS & JS files together that get used
  264. together. Using this will make your pagespeed score go down as there will be
  265. more css/js files to download but if different css/js files are used on
  266. different pages of your site this will be a net win as a new full aggregate will
  267. not have to be downloaded, instead a smaller aggregate can be downloaded,
  268. ideally with only the css/js that is different on that page. You can select how
  269. many bundles to create and the bundler will do it's best to meet that goal; if
  270. using browser css/js conditionals (js browser conditionals backported from D8
  271. https://drupal.org/node/865536) then the bundler might not meet your set value.