In Drupal 8, unless explicitly requested, core javascript is not loaded into the head of the document (ie: no jQuery). At first I thought this was a bug with core but it appears to be working as designed (https://drupal.org/node/1764252).
In a module I'm playing with in D8, I've used brute force to load core scripts by loading an empty javascript file from my module with dependencies to the core scripts using hook_library_info(). I would have thought that this would be possible via the Libraries module's hook_libraries_info() but it doesn't seem to do that. Is there a best practice for loading up core scripts when using Libraries and hook_libraries_info()?
Thanks,
Andrew
Comments
Comment #1
awasson CreditAttribution: awasson commentedAfter some back and forth on the Core issue queue, I've come to think that this is a bug rather than a documentation issue so I've updated and changed the category.
Comment #2
awasson CreditAttribution: awasson commentedAny advice about this issue?
Thanks,
Andrew
Comment #3
wwedding CreditAttribution: wwedding commentedThis is an older issue/support request so maybe this isn't relevant anymore, but...
The best practice would be to not use Libraries API to try to load Core libraries and instead use the methods provided by Drupal directly. The intent of this module is to load external software libraries/dependencies that don't come with Core but also can't (or shouldn't) be included in your module's code directly. Like TCPDF or tinyMCE.
The issue linked in the original description explains what is required to include JavaScript libraries now, perhaps it didn't when you originally filed it? Maybe I misunderstand your intent.
Comment #4
awasson CreditAttribution: awasson commentedYeah, pretty ancient issue so things have probably changed since then. At the time, when I wrote the issue, including dependencies in mymodule.libraries.yml didn't work so I suspect it's been fixed since. I'll have to give it a spin and see. The workaround is to use hook_library_info() to load dependencies but that's a bit messy.