In Drupal 8 some javascript changes were introduced so now all js scripts should be defined using hook_library_info()
and added to the page only with #attached
attribute of the render array.
But what best practices are recommended to define external libraries? Should we create /libraries
directory and upload library there? Or should they be managed by the module using composer?
So how should be the javascript library defined in hook_library_info()
in Drupal 8?