Been thinking about this quite a bit and it seems like it would be beneficial.

Comments

mikeytown2’s picture

Good example of this in found here: #1192422-14: Bundler logics documentation

AdvAgg says this is a good group of files based off the sites usage pattern

sites/all/modules/admin_menu/admin_menu.js
sites/all/modules/devel/devel_krumo_path.js
sites/all/modules/devel/devel.js
sites/all/modules/admin_menu/admin_devel/admin_devel.js
misc/drupal.js
misc/jquery.once.js

In reality this is what gets outputted by the bunder since it will not change the order

[jquery.once.js, drupal.js]
[states.js]
[form.js]
[admin_devel.js, admin_menu.js, devel_krumo_path.js, devel.js]
[textarea.js]
[collapse.js]

Looking at this the optimal thing to do is make sure states.js and form.js load after devel.js. I should be able to generate advice like this already from the data stored in the DB, just need to query it and then create a report.

The result would look like this

[jquery.once.js, drupal.js, admin_devel.js, admin_menu.js, devel_krumo_path.js, devel.js]
[states.js]
[form.js]
[textarea.js]
[collapse.js]

Report query was sorta worked on in this issue #2426285: Better bundling algorithm; change file order if possible.

mikeytown2’s picture

Good idea was brought up here #1192422-19: Bundler logics documentation. Just work on auto optimizing core css/js ordering. Use a form of the dependencies array found in hook_library so someone using drupal_add_js or hook_js_alter can add the dependencies in and let advagg do the rest.

The reorder algorithm would run after the analysis query but before the merging function of the bundler. This would be a checkbox setting. If a file lists no dependencies then nothing above it can move below that file.

mikeytown2’s picture

Title: Have an admin section of the bundler offer ordering analysis/advice » Have an admin section of the bundler offer ordering analysis/advice; build out the core dependencies and create a reorder function/algorithm
mikeytown2’s picture

Answer might be in here

header('Content-Type: text/plain');
$result = db_query("
SELECT
  advagg_files.filename,
  advagg_aggregates.porder - a.porder AS location,
  advagg_aggregates.porder AS `order`,
  -- advagg_files.changes,
  count(advagg_aggregates.filename_hash) AS counter
FROM `advagg_aggregates`
INNER JOIN `advagg_files`
  ON advagg_files.filename_hash = advagg_aggregates.filename_hash
INNER JOIN (
  SELECT
    advagg_aggregates.porder,
    advagg_aggregates.aggregate_filenames_hash
  FROM `advagg_aggregates`
  INNER JOIN `advagg_files`
    ON advagg_files.filename_hash = advagg_aggregates.filename_hash
  INNER JOIN `advagg_aggregates_versions`
    ON advagg_aggregates_versions.aggregate_filenames_hash = advagg_aggregates.aggregate_filenames_hash
    AND root = 1
  -- 'misc/jquery.once.js'
  WHERE advagg_aggregates.filename_hash = 'iUVyBLVVmAsFWnYi5FAG4DrjaZoffblUg4Yqt4cBKRI'
) AS a
  ON a.aggregate_filenames_hash = advagg_aggregates.aggregate_filenames_hash
GROUP BY advagg_aggregates.filename_hash
ORDER BY
  counter DESC,
  location ASC
");

drupal_load('module', 'advagg_bundler');
$bundler_analysis = advagg_bundler_analysis();


foreach ($result as $record) {
  if (isset($bundler_analysis[$record->filename])) {
    $record->bundler_analysis = $bundler_analysis[$record->filename]['group_hash'];
  }
  print_r($record);
}
mikeytown2’s picture

Status: Active » Closed (won't fix)

Too hard to pull off currently.