Investigating slow pages in http://drupal.org/node/1235408. Found the Superscript inline Javascript twice. I assume part of the slowdown would be the Superfish function running twice. As a quick fix, I added the following code and the Javascript appeared once instead of twice.

function superfish_contents($delta = 0) {
  global $language;
  static $superfish_javascript_added;

    if(empty($superfish_javascript_added))
    {
    $superfish_javascript_added = true;
    drupal_add_js($javascript, array('type' => 'inline', 'weight' => 100));
    }

The CSS appears only once. I think Drupal ignores duplicate inclusion of files but not duplicate inclusion of inline code. Perhaps the duplicate prevention could be wrapped around the whole process to reduce duplicate processing overhead.

The page uses fusion starter subtheme with only a few changes to the CSS. None of the other processing is changed. Why would the superfish_contents function fire twice?

Comments

mehrpadin’s picture

Hey Peter,

No duplicates there, you probably have two Superfish blocks.

peterx’s picture

One navigation block in the sidebar. One superfish block in the header. I added a trace to the code. When the superfish block is on, the superfish_contents function runs twice. When the superfish block is off, the code runs once. It is the Superfish block running the superfish_contents function twice.

peterx’s picture

I found the error occured with Fusion but not with Zen as the base theme.

mehrpadin’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

avb’s picture

Status: Closed (fixed) » Active

The same bug is appearing on my site using the fusion theme and having only one superfish block enabled.

mehrpadin’s picture

Servus,

If it's only happening with the Fusion you should ask the developers of the Fusion about this.

mehrpadin’s picture

Status: Active » Closed (works as designed)