mollom.js only contains functions used with Drupal.behaviors. These are not executed until the whole page has loaded, so there is no reason to load the file already in the <head> element.

Also, AFAICT mollom.js is not used in mollom.admin.inc.

Comments

Status: Needs review » Needs work

The last submitted patch, mollom-footer-1.patch, failed testing.

dries’s picture

Version: 6.x-1.13 » 7.x-1.x-dev
Status: Needs work » Patch (to be ported)

Committed to DRUPAL-6--1 -- the test failure has nothing to do with this patch. Needs to be ported to Drupal 7.

dave reid’s picture

Status: Patch (to be ported) » Fixed
StatusFileSize
new704 bytes

Here's the same patch for 7.x, and committed to CVS.

dave reid’s picture

Status: Fixed » Needs review

Actually I'd love just to see how tests are doing in D7. :)

Status: Needs review » Needs work

The last submitted patch, 781994-mollom-footer-js-D7.patch, failed testing.

dave reid’s picture

Status: Needs work » Fixed
sun’s picture

I'm a bit baffled by this change. The stated reason for loading the JavaScript in the footer was

These are not executed until the whole page has loaded, so there is no reason to load the file already in the <head> element.

But given that intention, changing the scope is the wrong optimization. Instead, it's the defer attribute that would have to be added for mollom.js.

Merely changing the scope can easily lead to the opposite of the intention (assuming frontend performance): mollom.js is no longer aggregated if JS aggregation is enabled.

Overall, you'd have to apply the same scope change to almost every other module and JS file that runs on your site. I am well aware of the fact that loading JS in the footer (if possible) is a known frontend performance optimization. But if you really want to apply it globally, then we should change the default scope in Drupal core instead, and users of current core versions may rescue to contributed modules that allow to configure this optimization.

c960657’s picture

defer would be better, at least with modern browsers. But can we be sure that behaviors are attached if the deferred file finishes loading after the $(document).ready() is fired?

Merely changing the scope can easily lead to the opposite of the intention (assuming frontend performance): mollom.js is no longer aggregated if JS aggregation is enabled.

Scripts inserted into 'footer' are aggregated too. But aggregation requires that at least one other JS file is inserted here.

After having files this issue I noticed that Drupal core inserts scripts using the defaults a lot of places where scope == 'footer' or 'defer' => TRUE could have been used instead. I have just filed #784626: Default all JS to the footer, allow asset libraries to force their JS to the header.

Overall, you'd have to apply the same scope change to almost every other module and JS file that runs on your site.

True. I hope we can decide on a general recommendation for this in #784626: Default all JS to the footer, allow asset libraries to force their JS to the header that other modules may follow. But for now this change is perhaps too “avant garde” for Mollom.

sun’s picture

admin_menu successfully uses the defer attribute since Drupal 5, so yes, it works how it's supposed to work. And, yes, most JS in Drupal could technically use the defer attribute.

dave reid’s picture

Status: Fixed » Active

Should we roll this back? It doesn't seem like a worthwhile change especially since it can't be aggregated now.

c960657’s picture

Agreed. We should roll it back until a conclusion has been reached in #784626: Default all JS to the footer, allow asset libraries to force their JS to the header.

Sorry for jumping the gun on this. It was my impression that 'footer' was already widely used.

Note that the D6 patch does not roll back the change to mollom.admin.inc. That change is unrelated to the header/footer discussion.

dave reid’s picture

Assigned: Unassigned » dave reid
Status: Active » Needs review
dries’s picture

Status: Needs review » Fixed

Rolled back in DRUPAL-6--1 and CVS HEAD. Back to 'fixed', I guess.

Status: Fixed » Closed (fixed)

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

  • Commit 27f3a6b on master, fai6, 8.x-2.x, fbajs, actions by Dave Reid:
    #781994 by c960657: Load mollom.js in scope 'footer'.
    
    
  • Commit 78f05a7 on master, fai6, 8.x-2.x, fbajs, actions by Dries:
    - Patch #781994 by c960657: rolled back loading mollom.js in scope '...

  • Commit 27f3a6b on master, fai6, 8.x-2.x, fbajs, actions by Dave Reid:
    #781994 by c960657: Load mollom.js in scope 'footer'.
    
    
  • Commit 78f05a7 on master, fai6, 8.x-2.x, fbajs, actions by Dries:
    - Patch #781994 by c960657: rolled back loading mollom.js in scope '...