Download & Extend

'da2a is not defined' error when using Headjs or Labjs

Project:Share Buttons (AddToAny) by Lockerz
Version:7.x-3.1
Component:User interface
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (works as designed)

Issue Summary

My site got a lot of script files so I want use the Headjs or Labjs to download them in parallel, hopefully for better performance.

However, after either of them is enabled, the AddToAny doesn't work, and the firebug captures an error of 'da2a is not defined'. When being hovered over, the 'Share' link behaves like it's dead and doesn't prompt the share menu.

The following is the difference I found before and after I enable the Labjs module:

  • The share link
  • <a id="da2a_1" class="da2a_button" href="http://www.addtoany.com/share_save#url=http%3A%2F%2projectwhatever.dev%2Fnode%2F4003&title=this%3A%20problem%20is%20%&description="> Share</a>
  • The script in header
  • <script type="text/javascript">
    <!--//--><![CDATA[//><!--
    var a2a_config=a2a_config||{},da2a={done:false,html_done:false,script_ready:false,script_load:function(){var ........................2a_config.tracking_callback=['ready',da2a.script_onready];
    //--><!]]>
    </script>
  • The script in footer
  • <script type="text/javascript">
    <!--//--><![CDATA[//><!--
    da2a.targets=[
    {title:'node title for node 4003',url:'http://myproject74.dev/node/4003'}];
    da2a.html_done=true;if(da2a.script_ready&&!da2a.done)da2a.init();da2a.script_load();
    //--><!]]>
    </script>

But when it doesn't work:

  • The share link
  • <a class="da2a_button" href="http://www.addtoany.com/share_save" id="da2a_1"> Share</a>

    The query string after 'share_save' disappear
  • The script in the header
  • <script type="text/javascript">
    <!--//--><![CDATA[//><!--
    $LAB.queue(function() {
    var a2a_config=a2a_config||{},da2a={done:false,html_done:false,script_ready:false,script_load:function(){var ..................ge',{target:el});da2a.done=true;}}};a2a_config.tracking_callback=['ready',da2a.script_onready];
    });
    //--><!]]>
    </script>
  • The script in the footer
  • <script type="text/javascript">
    <!--//--><![CDATA[//><!--
    $LAB.queue(function() {
    da2a.targets=[
    {title:'node title for node 4003',url:'http://myproject74.dev/node/4003'}];
    da2a.html_done=true;if(da2a.script_ready&&!da2a.done)da2a.init();da2a.script_load();
    });
    //--><!]]>
    </script>

After I disable either of Labjs or Headjs, everything turns OK again.
What may cause this problem and is there anyway to get around this? Thanks.

Comments

#1

Status:active» closed (works as designed)

I don't have experience with Headjs or Labjs, though I can say that modifying the inline JavaScript will indeed mess with the performant asynchronous loading of the external script. In fact, as you discovered, the script won't load at all if the inline JavaScript is removed!

This is more of an issue for Headjs or Labjs to tackle, though feel free to reply with thoughts/solutions. This module's maintainers are always open to discussion about elegant solutions to cross-module conflicts. :)