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

CommentFileSizeAuthor
#3 writeTags.patch737 bytesbleen
#1 doc-write-1146080.patch1 KBgansbrest

Comments

gansbrest’s picture

Status: Active » Patch (to be ported)
StatusFileSize
new1 KB

Here is the patch. As you can see it's super simple, but provides more options to work with.

bleen’s picture

Status: Patch (to be ported) » Needs review

At 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.

bleen’s picture

StatusFileSize
new737 bytes

I 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?

bleen’s picture

Title: Get rid of document.write in dart.js » Allow override of document.write in dart.js
Status: Needs review » Fixed

I went ahead and committed #3

gansbrest’s picture

I think that's a good idea! I didn't have time to play with it yet, but I think it should work.

Status: Fixed » Closed (fixed)

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

bleen’s picture

Followup on writeCapture can be found at #1183718: Make ads work within AJAX -ically loaded content