Problem/Motivation
for #1988968: Drupal.ajax does not guarantee that "add new JS file to page" commands have finished before calling said JS we need a reliable solution for loading js files and know when the file has finished loading.
loadjs is a working, stable solution to load scripts/css/assets and know when they loaded. It is also tiny: only 899 bytes!
Steps to reproduce
N/A
Proposed resolution
N/A
Dependency evaluation
- Maintainership of the package: created and maintained by Andres Morey
- Security policies of the package: none I could find
- Expected release and support cycles: I don't see any roadmap, last release was 3 years ago. package is feature complete so i wouldn't expect new releases.
- Code quality: code is easy to read and understand, uses jshint to validate code style, there is a pretty comprehensive test suite
- Other dependencies: no runtime dependencies, dev dependencies are gulp and jshint
The code is pretty straightforward, we could probably roll our own if necessary, the heavy lifting can be done with something like this. Better to use something battle-tested though, especially when it's small like this.
Remaining tasks
patch
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
N/A
Issue fork drupal-3228351
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3228351-add-loadjs-library changes, plain diff MR !1064
Comments
Comment #3
nod_Comment #4
Wim LeersDiff looks great — the key remaining thing here is the evaluation of this library 👍
Since this blocks a major, marking as such.
Comment #5
Wim LeersComment #6
nod_added library evaluation
author is working on a dependency manager https://github.com/muicss/johnnydepp that uses the loadjs lib so it's good enough to reuse after several years in another project :)
Comment #7
Phil Wolstenholme CreditAttribution: Phil Wolstenholme commentedThis isn't a formal evaluation, but we've (a Drupal agency in the UK) been using LoadJS (via the 'Drupal.ajax does not guarantee that 'add new JS file to page' commands have finished before calling said JS' patch from the previous DO issue) since 8 Feb 2020 and I've grown to really love it.
It fixes the
Drupal.ajax
issue, which is great, but I've also been using it for some performance enhancements too:All of the above I could have done manually of course, but having LoadJS available in Core (via the patch) made it so easy :)
We use it on sites like https://www.ltmuseum.co.uk that are relatively highly trafficked and we haven't seen any bugs related to LoadJS, so it's a +1 for bringing it into Core from me!
Comment #8
Wim Leers🤣🤣🤣
Comment #9
Wim LeersThanks for adding the library evaluation!
https://github.com/muicss/loadjs/blob/master/src/loadjs.js is 305 lines in total.
\Drupal
(that iscore/lib/Drupal.php
) does nothing and has more than twice as many lines.The tiny size, the low complexity, complete test suite combined with the endorsement in #7 are reason enough for me to mark this RTBC.
I can't wait to see #1988968: Drupal.ajax does not guarantee that "add new JS file to page" commands have finished before calling said JS getting unblocked!
Comment #10
lauriiiSince this adds a new dependency, this needs to be reviewed by a release manager
Comment #11
catchUsually when this is the case we open an issue on github and ask if they have an informal/undocumented policy for what they would do in the case of a vulnerability.
If the answer is 'we don't have one' that's OK, but in the past we've ended up with something basic we could document.
Everything else looks good to me on the dependency evaluation.
Comment #12
xjmI think we could still open a short issue in their queue asking if they could define a security policy using the GH feature with some of the questions we normally ask, but given that this is a very small amount of code to fork if it should become necessary, I don't think we would need to block committing this on an answer.
Comment #13
catch#12 works for me too, removing the needs RM review tag.
Comment #14
nod_posted: https://github.com/muicss/loadjs/issues/106
Comment #16
catchReally nice and encouraging response on github. Let's get this in.
Committed fe2e7c3 and pushed to 9.3.x. Thanks!
Comment #17
andypostAs there's no CR maybe release note snippet is needed?
Comment #20
AnybodyFollow-up: #3336143: Uncaught ReferenceError: loadjs is not defined after drupal core upgrade 9.5.1