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.
Currently the code for _easy_social_render_widgets()
does not invoke drupal_add_js()
properly. It passes a string value "external" as $script_type
for external scripts as the second argument:
if ($script_type !== 'module') {
drupal_add_js($script['path'], $script_type);
}
To properly pass the "external" value, it should be an $options array:
https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_...
Additionally, external libraries should be scoped to the footer by default to prevent a slow external service from blocking a page from rendering.
Comment | File | Size | Author |
---|---|---|---|
#4 | easy_social-footer_scope_2342875_4.patch | 1.21 KB | Andrew Edwards |
#1 | footer_scope_2342875.patch | 1.33 KB | joshk |
Comments
Comment #1
joshk CreditAttribution: joshk commentedPatch attached.
Comment #2
timani CreditAttribution: timani commented+1 to changing loading of the JS to avoid blocking of page rendering, ideally async.
Moving this to the footer should also help to defer JS loading:
https://developers.google.com/speed/docs/insights/BlockingJS
Comment #3
Andrew Edwards CreditAttribution: Andrew Edwards commentedWorks for me. Thanks! My pages were often getting blocked by easy social js, and now they are blocked no more.
Comment #4
Andrew Edwards CreditAttribution: Andrew Edwards commentedAdjusting the patch to be from the module folder instead of site root.
Comment #5
Andrew Edwards CreditAttribution: Andrew Edwards commented