Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When I enable Labjs, the AddToAny module stops working.The same problem exists for the HeadJs module as well.
Comment | File | Size | Author |
---|---|---|---|
#6 | addtoany.patch | 700 bytes | jcisio |
Comments
Comment #1
jcisio CreditAttribution: jcisio commentedCan you check again with the latest snapshot of LABjs (31 Jul)?
Comment #2
kurtzhong CreditAttribution: kurtzhong commentedBut my I am using drupal 7.4, and the version you mentioned it for Drupal 6.
Because the AddToAny module has two inline scripts, one in the header and one in the footer respectively. If the Labjs could exclude them from the chain, I think things will be ok.
Comment #3
jcisio CreditAttribution: jcisio commentedI push the changes yesterday but I don't know why there is no new developement snapshot in 7.x branch yet. The changes are in http://drupalcode.org/project/labjs.git/commit/4c5e58a and http://drupalcode.org/project/labjs.git/commit/e4544d4
Comment #4
jcisio CreditAttribution: jcisio commentedI've found the problem. 7.x-1.x-dev was tracking in the master branch that I stopped on it for a while and switch to 7.x-1.x branch. I fixed it. Hope a new snapsnot will be available soon.
Comment #5
kurtzhong CreditAttribution: kurtzhong commentedThank you jciso. I've checked the latest snapshot, but still not working. There's a inline js code output from AddToAny module which is not captured by Labjs, and it shouldn't executes before other two inline javascripts on which it depends.
Comment #6
jcisio CreditAttribution: jcisio commentedThe following patch for addtoany will have inline script wrapped by LABjs. Well, it also a more D7-way to insert inline script.
But the way that AddToAny use async to do several attempts to load the script make it difficult for LABjs to intervene. I'll debug a little bit further.
Comment #7
jcisio CreditAttribution: jcisio commentedThe problem is that when inline script is wrapped by LABjs, variable scope change.
After that block, a2a_config and da2a is no longer available. There are two solutions:
- Wrap them into Drupal (like Drupal.a2a.config = ..., Drupal.a2a.d = ...)
- Put them into a JS file (like the case "Drupal" variable is put into misc/drupal.js).
I'm sorry to pass this issue into a2a. But it's a more "Drupal way" to do ;-)
Comment #8
kurtzhong CreditAttribution: kurtzhong commentedSo appreciated to see your patch on a2a and two constructive solutions. Although it's not working yet, I don't see the 'da2a not defined' error anymore. I am not good at javascript and know little about drupal's js mechanism, but you really help me with understanding this issue a lot. Thank you very much :)
Comment #8.0
kurtzhong CreditAttribution: kurtzhong commentedUpdated issue summary.