Hi,
Recently I was playing around with the Dart module and noticed a problem when I moved $scripts to the bottom of the page (we do that pretty often).
Naturally I've got an error that Drupal is undefined which is understandable.
What I propose, is to move document.write() out of the dart.js and move it to dart_tag.tpl.php. Since we can easily override template files in Drupal, we will get much more flexible system. For example you can render ads after HTML was loaded and keep JS files on the bottom.
Also I did try to use writeCapture library and play nicely with Dart.
I will provide a patch soon. Please review.
Thanks
Comments
Comment #1
gansbrest commentedHere is the patch. As you can see it's super simple, but provides more options to work with.
Comment #2
bleen commentedAt first glance this seems like a good thing ... I'm going to let this marinate for a bit though because I have this irking feeling that there was some reason that I can no longer recall that I moved that document.write into the js file.
In other news, this is the first I'm learning about writeCapture ... Ill definitely look into this.
Comment #3
bleen commentedI dont want to commit the patch submitted in #1 because this will break any site that already has dart_tag.tpl.php ... What do you think of this patch as an alternative?
All you'd need to do is override the Drupal.DART.settings.writeTags variable and you can achieve what you want. Thoughts?
Comment #4
bleen commentedI went ahead and committed #3
Comment #5
gansbrest commentedI think that's a good idea! I didn't have time to play with it yet, but I think it should work.
Comment #7
bleen commentedFollowup on writeCapture can be found at #1183718: Make ads work within AJAX -ically loaded content