I am doing a quick review of the module and one the first things I noticed is that there is no ivw_integration.libraries.yml
but there seems to be a reference to a library in the function ivw_integration_page_attachments
$page['#attached']['library'][] = 'ivw_integration/ivw_call';
Can you clarify why that line exists?
In general I think it will be better to use the Drupal libraries mechanism for the whole module that is intended to add JS to the page. Using a block seems a bit weird.
Maybe the google analytics module is a good example on how to achieve such a thing.
Have you considered refactoring the code to use Drupal libraries?
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | unnecesarry_library_attachment.patch | 436 bytes | pagach |
Comments
Comment #2
daniel.bosenThe library should only be added, when necessary. the drupal libraries mechanism always adds the library but with attachments its only added when actually needed
Comment #3
rodrigoaguileraFor the sake of clarity the libraries mechanism allows for conditional inclusion.
https://www.drupal.org/docs/8/creating-custom-modules/adding-stylesheets...
You can also add settings for the variables you need available on JS. This is why these mechanisms exists and it also allows for the script to be loaded in the footer of the page, aggregate it and all the benefits of doing it the "Drupal-way"
Aside from the the discussion about using libraries or not there is still a bug about the library reference that is stated in the title. That is why I'm reopening.
Comment #4
pagach commentedshouldn't the library still be defined in .libraries.ymf file even if it is loaded via attachments?
here's a patch with removed ivw_integration/ivw_call libray call
Comment #5
rodrigoaguileraThere is no point in keeping the libraries.yml file if no code is using it
Comment #6
alexpottYep this library does not exist.