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?

CommentFileSizeAuthor
#4 unnecesarry_library_attachment.patch436 bytespagach

Comments

rodrigoaguilera created an issue. See original summary.

daniel.bosen’s picture

Status: Active » Closed (works as designed)

The library should only be added, when necessary. the drupal libraries mechanism always adds the library but with attachments its only added when actually needed

rodrigoaguilera’s picture

Status: Closed (works as designed) » Active

For 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.

pagach’s picture

StatusFileSize
new436 bytes

shouldn'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

rodrigoaguilera’s picture

Status: Active » Reviewed & tested by the community

There is no point in keeping the libraries.yml file if no code is using it

alexpott’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev
Category: Support request » Bug report
Status: Reviewed & tested by the community » Fixed

Yep this library does not exist.

  • alexpott committed fd17eb5b on 8.x-2.x
    Issue #3004286 by pagach, rodrigoaguilera: Reference to non-existing...

Status: Fixed » Closed (fixed)

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