Hi!

I noted that all my pages, even the admin ones, were really slow before I install the AddThis modules.
And with a little debug i findout that all the Js and Css files for the widget were being loaded in every page.

So I made a not definitive patch(I guess) to this problem, creating a checkbox to disable the "every page load", and it will only appears if you install the "addthis_displays". And now only will be loading the AddThis files when a field is being view.

I hope others understand my problem, and help me to make a better solution to this.

Cheers!,
Sebas.

Proposed solution

Only load the widget and related resources when displaying a AddThis share widget.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sebas5384’s picture

matglas86’s picture

I think I would like to do something like using path_is_admin and exclude it there. Or do a lazy loading on specific javascript. Like when I find addthis link decoration act and load the library. We can do that with jQuery easily.

I think the patch from #1 is a little to much.

sebas5384’s picture

I just dont want to load the addThis libraries in pages that there is not need for it.

With Javascript lazy loading can be a probably solution, but in some way you are loading other javascripts files you dont need.

My point is, dont load anything in the front, that you dont't really need.

Matthew Davidson’s picture

A real edge case, but related, is that when you're a tinfoil hat wearer like myself and use the Firefox Ghostery addon to block spyware scripts like AddThis, ajax callbacks on admin pages are clobbered by:

window.addthis.ready is not a function

... rendering - among other things - content type configuration impossible. It took me way too long to work out why this was happening, so solving the above problem will help here as well.

tim.plunkett’s picture

Version: 7.x-4.0-alpha1 » 7.x-4.x-dev
Category: feature » bug

This is a bug.

tim.plunkett’s picture

Priority: Normal » Critical

Doing load tests on a site using AddThis, I found some startling results.

On a page that has no AddThis widgets loaded, and no need for the AddThis code at all, all of the assets are still loading.
It is comprising 60% of the HTTP requests and 25% of the load time.

This is when it's not needed at all.

charizard’s picture

Hi, we've encountered the same problem in #4, and had a quickfix for it in the patch.

This is only a quickfix so we can still use the normal functionality of Drupal without addthis breaking it, this won't prevent addthis from trying to load itself on every page. It simply skips calling window.addthis.ready().

Hope that this helps someone in the mean time before addthis is fixed up properly to degrade gracefully without affecting other javascript when ghostery and other privacy related features are enabled.

matglas86’s picture

matglas86’s picture

I added a load function that load only once when a getDisplayMarkup is called. So only when a specific display is called for display in a page we load the widget. Otherwise you have to call it by hand.

I added a patch that implements this and includes the fix for the non existing addthis.ready function.

matglas86’s picture

If I don't receive feedback in the coming week I'm going to apply the patch and close the issue. I want to make some progress on the issues.

matglas86’s picture

Status: Needs review » Fixed

Now commited and fixed. I any issues arise again please open a new issue.

Commit: a7254

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.