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.
All social plugins in this module (facebook, twitter, google plus, and linked-in) have a certain way to load the javascript asynchronously. According to common belief, loading javascript asynchronously should help to decrease page load time.
If I look into the code of this module, currently there is no option to load javascript asynchronously. I'm sure the author of this plugin has some reasons for this decision.
But, I think it should be nice if there is an option to use asynchronous version of javascript instead of synchronous one.
Comment | File | Size | Author |
---|---|---|---|
#10 | 1630028-10-easy-social-async.patch | 7.16 KB | chr.fritsch |
#8 | 1630028-8-easy-social-async.patch | 5.58 KB | fearlsgroove |
#7 | 1630028-7-easy-social-async.patch | 5.58 KB | fearlsgroove |
#5 | 1630028-7502434-async-load-libraries.patch | 5.22 KB | angrytoast |
#2 | 1630028-async-load-libraries.patch | 2.97 KB | angrytoast |
Comments
Comment #1
lnunesbrganagus, thanks for asking... actually, there is already a thread for that #1447522 that considers the implementation of Socialite.js for a more 'softly' loading of the widgets... please, keep an eye on there...
Comment #2
angrytoast CreditAttribution: angrytoast commentedFollowing up on the issue, but there appears to be little progress on the socialite integration at https://drupal.org/node/1447522.
So, I came up with a patch.
Proposed Solution:
An async solution if the library is set to external (any third party libraries), using an async loading pattern for all external libraries. I don't see a reason to include libraries scripts in a non-async pattern, but would be glad to hear about why there should be such an option.
patch attached:
Comment #3
fearlsgroove CreditAttribution: fearlsgroove commentedThis patch works great and mitigates a really impactful downside to social plugins. I'd love to see this commited while waiting for progress on the Socialite.js approach.
Comment #4
claes nilsson CreditAttribution: claes nilsson commentedI would really like to see this feature in the 6x version if possible
Comment #5
angrytoast CreditAttribution: angrytoast commentedRealized the previous patch has a dumb loop placement which just happened to work. But here's an updated one, and also includes offloading the facebook script to the external loaded script set. The Facebook change isn't completely necessary, but does allow for moving the script loading to after window onload event.
On that note, also changed the logic to grabbing the externals on window load rather than DOM ready, may be set this as a admin option? Thoughts?
Comment #6
fearlsgroove CreditAttribution: fearlsgroove commentedIt's going to need to be on dom ready to ensure widgets that rely on markup to replace have their needed markup already loaded.
Comment #7
fearlsgroove CreditAttribution: fearlsgroove commentedApparently that version will also duplicate the externals references due to the way drupal_add_js works with settings. Here's a version that stores the externals and applies via a page_alter hook (probably requires a cache clear due to new hook)
Comment #8
fearlsgroove CreditAttribution: fearlsgroove commentedErp whitespace error
Comment #9
wiifmCode looks nice, have tested with Google and Twitter, both work well. Was unable to test the facebook loading due to the fact that we use the iframe version.
This is a massive improvement. +1 from me.
Comment #10
chr.fritschPatch against current version
Comment #11
rt2sd CreditAttribution: rt2sd commentedI would love to see this merged in an official release.
We should all care about async loading because it does affect page loading time and therefore SEO.
I can sponsor a bit if it helps.
Comment #12
TheLioness22 CreditAttribution: TheLioness22 commentedI came across this issue queue after looking for an "asynchronous mode" checkbox in the easy_social settings (which wasn't there). I will try out the patch, if I can figure out how to apply it. I hope to see this functionality rolled into the main release. Personally, I think asynchronous load should be enabled by default (for any social buttons that support it), and need to be disabled to use the other. Some may disagree, however. Regardless, I think both options should be available in the module for any social buttons that support asynchronous load.
Comment #13
sja1 CreditAttribution: sja1 commentedPatch 10 is working for me.
Comment #14
klidifia CreditAttribution: klidifia commented10 fine -- So the difference between 8 and 10 is basically just coding standards, no functionality change, so RTBC as per #9.
Comment #15
rhormens CreditAttribution: rhormens at CI&T commentedHi guys,
Error applying path, please fix
Please fix in branch 7.x-2.x.
Thanks
rhormens
Comment #16
rhormens CreditAttribution: rhormens at CI&T commentedComment #17
Donit CreditAttribution: Donit commentedTrue, patch needs a rework. Subscribe.