Problem

  1. There is no sensible 'version' for JS/CSS registered by (contrib) modules via hook_library_info().

        'version' => '1.0',
    
  2. The loaded files will not update, unless the version number is manually increased with every single change to a file.

        'version' => '1.0',
        'js' => array(
          $path . '/admin_menu.js' => $options,
        ),
    ... :: ...
      <script src="/modules/admin_menu/admin_menu.js?v=1.0"></script>
    

    (The query string was based on filemtime previously, properly detecting any changes.)

  3. Library identifiers à la 'drupal.admin' are unclear and undocumented, and the current identifiers found throughout core make no sense at all.

      // This library DOES NOT provide 'Drupal.Admin'. WTF?
      $libraries['drupal.admin'] = array(
    
  4. It's entirely unclear how to add conditional JS/CSS that extends some other JS/CSS.

      $attached['css'][$path . '/admin_menu.css'] = $options;
      if ($user->uid == 1) {
        $attached['css'][$path . '/admin_menu.uid1.css'] = $options;
      }
    
  5. jQuery, jQuery.once, and Drupal libraries by System do not specify 'every_page' => TRUE anymore, breaking the entirety of JavaScript aggregation optimizations that have been carefully designed.

      $libraries['drupal.admin'] = array(
        'js' => array(
          $path . '/admin_menu.js' => array('every_page' => TRUE),
        ),
        'css' => array(
          $path . '/admin_menu.css' => array('every_page' => TRUE),
        ),
        'dependencies' => array(
          array('system', 'drupalSettings'),
          array('system', 'jquery'),
          array('system', 'drupal'),
          array('system', 'jquery.once'),
        ),
    ... :: ...
    <script src="/modules/admin_menu/admin_menu.js?v=1.0"></script>
    <script src="/core/misc/jquery.js?v=1.8.2"></script>
    <script src="/core/misc/jquery.once.js?v=1.2"></script>
    <script src="/core/misc/drupal.js?v=8.0-dev"></script>
    
  6. Various core libraries are registered with hard-coded weights that do not leave any room for contrib to inject themselves in between:

          'core/misc/tabledrag.js' => array('group' => JS_LIBRARY, 'weight' => -1),
    
  7. ALL JS and CSS added through drupal_add_library() gets the group of JS_LIBRARY, which destroys the entire sense of the previous separation between library vs. consumer/integration files.

        'css' => array(
          $path . '/admin_menu.css' => $options,
        ),
    ... :: ...
    <style media="all">
    @import url("http://drupal8.test/sites/all/modules/admin_menu/admin_menu.css?mbhc0i");
    </style>
    <style media="all">
    @import url("http://drupal8.test/core/modules/field/theme/field.css?mbhc0i");
    @import url("http://drupal8.test/core/modules/user/user.css?mbhc0i");
    @import url("http://drupal8.test/sites/all/modules/admin_menu/admin_menu.uid1.css?mbhc0i");
    </style>
    

Comments

sun’s picture

Issue tags: +frontend performance
sun’s picture

Yuck. Added problem 6. and 7.

sun’s picture

Issue tags: +Release blocker

I don't think we can release with this, so tagging accordingly. Don't want to bump to critical, since this will take some time to resolve...

nod_’s picture

I'll keep it short, hopefully giving enough feedback.

  1. For contrib using VERSION doesn't make sense, that's right. It does make sense to have the module's version though.
  2. This problem show up in dev, this is a good thing as far as production goes.
  3. That's not very fair, have a look at system_library_info(): drupal, drupal.js ; drupal.tabledrag, tabledrag.js ; jquery.once, jquery.once.js, drupal.toolbar, toolbar.js, etc. Slight inconsistencies for drupal.js, jquery.js, farbtastic.js and the html5 shiv but contrib wouldn't run into that very often.
  4. I'm not getting what it's about. Isn't this already the case in D7?
  5. That's true, the aggregation is kind of a mess right now. It needs to be though out from the ground up, what we have might have been carefully designed but if you want to alter it you need to throw everything away and start from scratch. That's not very helpful.
  6. see above.
  7. see above.

The aggregation strategies can be thought out after feature freeze I'd say, what needs to happen now it cleaning the API and making it truly pluggable. The actual aggregation strategies can be refined later on.

pancho’s picture

Priority: Major » Critical
Issue tags: -Release blocker

Re #3:

"I don't think we can release with this, so tagging accordingly." means "critical", and I tend to agree. Anyway, we're way beyond thresholds both regarding critical and major bugs.
So all this "major plus 'Release blocker' tag" leads to is covering our real technical debt, as discussed on #1810428: [Policy, no patch] Adjust major and critical task thresholds during code thaw Which isn't good, even more because this specific issue will take quite some time to be properly solved.

nod_’s picture

update since last time:

  1. VERSION: it's being discussed in #1996238-34: Replace hook_library_info() by *.libraries.yml file too.
  2. Still only a problem in dev. When a website is in prod it'd work fine provided we have the module version in the library declaration. Also, aggregation renders this moot.
  3. touched a bit in #1996238-11: Replace hook_library_info() by *.libraries.yml file
  4. Still not getting it
  5. It's being addressed ATM https://drupal.org/node/2034675, it's not yet at the aggregation strategy step but many other ppl wants that fixed (including me).
  6. We shouldn't be using weights to begin with #1945262: Introduce "before" and "after" for conditional ordering in library definitions and the same ppl as above agree that a DAG is the best way to handle that. And I don't think I ever saw a restrictions that weights should be integers? infinity of numbers between two integers.
  7. True, but since it's used for aggregation and that needs to be dealt with regardless.
nod_’s picture

Priority: Critical » Major
Issue tags: +revisit before beta

I don't feel any of this is critical, several points are going to be addressed with other issues. Demoting to major and adding revisit before release tag in case we miss something with the other issues.

nod_’s picture

Issue summary: View changes

Updated issue summary.

catch’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: -revisit before beta

Anything left here that's not covered by #1996238: Replace hook_library_info() by *.libraries.yml file?

sun’s picture

Title: Module/Consumer JavaScript/CSS "library" does not have a version; expected library registry usage is undocumented » [meta] Asset library declarations, registry, usage, DX, compatibility, documentation
Component: base system » asset library system
Status: Postponed (maintainer needs more info) » Active

I went through a whole bunch of related issues and turned them into child issues of this issue.

→ Turning this issue into a meta.

Don't have the energy to rewrite the issue summary right now.

jhedstrom’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs issue summary update

Issue summary needs updating given the removal of hook_library_info().

wim leers’s picture

Assigned: Unassigned » nod_

I think the only thing left to do here, is rationalizing/analyzing our CSS aggregation.

The every_page system never actually made sense, because it is site-specific, even though it was always specified by an individual module. How can a module know whether e.g. the block the asset is for will be present on every page? It cannot, because it's site-specific.

Therefore, the only aggregation strategy that makes sense AFAICT, is analyzing our JS asset dependency graph, and always loading those assets that are most frequently depended upon. But even that is flawed: what if some JS that's only intended for admin users is amongst the most frequently depended upon JS assets?

Finally, and foremost: loading certain JS assets always for optimization purposes implies actively ignoring the dependency graph!

IMO improving front-end performance further in this area is something that can happen during a later release of Drupal 8. We already have sufficient front-end performance improvements: no JS for anonymous users out of the box, all JS loaded from the footer by default (opt-in to header instead of opt-out), some client-side caching, and so on. We should be correct/sane first, and optimize second.

Assigning to @nod_ to get his feedback, and give him the opportunity to close this one :)

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

nod_’s picture

Status: Postponed (maintainer needs more info) » Fixed
Issue tags: -JavaScript +JavaScript

All right, I think compared to the situation in 2012 we're in a good place.

From the summary 2 and 3 could still be an issue, although the fact that we have libraries.yml files makes the discovery easier.

We can close this one and work on the followups is necessary.

wim leers’s picture

🥳

Closed by @nod_ 5 years and 3 days after I suggested exactly that 😄 Blast from the past!

nod_’s picture

very efficient :)

Status: Fixed » Closed (fixed)

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