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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joshk’s picture

FileSize
1.33 KB

Patch attached.

timani’s picture

+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

Andrew Edwards’s picture

Works for me. Thanks! My pages were often getting blocked by easy social js, and now they are blocked no more.

Andrew Edwards’s picture

Adjusting the patch to be from the module folder instead of site root.

Andrew Edwards’s picture

Status: Active » Needs review