Currently, the sharethis js code is appened to each button wherever they appear on the page.

On a listing page with 50 items, this means the same javascript page is included 50 times, when in fact none of the code loaded is tied to any single instance on the page.

Moving the inclusion of the code to a single instance in the footer of the page will greatly increase the perceived load time of the page by allowing page content to load before inserting the share this button.

I've created a patch will I will add to this issue.

Comments

aacraig’s picture

StatusFileSize
new2.16 KB

Here is the patch.

I actually wrote the code using the 7.x-2.2 code base, and only when I checked out the dev version through git did I realize you've added a lot of code to this function.

I've rolled the patch against the dev version, but am not able to test it using that version at the moment. I have tested it on 7.x-2.2 and it works great, increasing the page load speed by 2 - 3 seconds on a page that loads 50 teasers.

chrishks’s picture

StatusFileSize
new2.16 KB

I noticed that if you want to set 'external' in the $options parameter of drupal_add_js like in the patch, then it needs to be in the form of 'type' => 'external' rather than 'external' => TRUE (which you can use in the $data parameter of drupal_add_js) - I had problems when enabling aggregration using the current patch. It's a small change but I have attached an amended patch.

vladimiraus’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Issue was inactive for more than 9 years. Closing.
Feel free to reopen if you feel that it is still relevant. ⏳