Clarify library_id vs module name confusion in hook_library_info_build code example.

Created on 20 March 2016, over 9 years ago
Updated 15 July 2025, about 18 hours ago

Problem/Motivation

When trying to implement hook_library_info_build I uncovered some confusion caused partly by the documentation provided in hook_library_info_build.

It seems that libraries are referenced according to "module_name/library_id" when referenced in #attached attributes, but the use of mymodule in the ID of the library leaves the impression that you're specifying the module name here.

Second confusion arose as to when this hook fires, as it turns out that you will only see the build fire when you are on a page that uses a library a library defined by the module as indicated by the naming convention. Although it's understanding why this is done, it probably bears calling out, especially since the #attached entity relationship is so important.

Proposed resolution

Include a #attached reference example for the module/library that is being defined in the example. Call out specifically that this hook fires the first time a page is visited that has a #attached reference for libraries provided by the providing module.

User interface changes

None

API changes

None

Data model changes

None

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States metzlerd

Live updates comments and jobs are added and updated live.
  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for creating this issue to improve Drupal.

    We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024