Okay
  Public Ticket #148946
Theme Options "Custom Javascript"
Closed

Comments

  • Clint started the conversation
    I am using v1.4.1 of PowerMag theme and Appearance > Theme Options > Custom Javascript is inserting the code into the footer instead of the header. How would I fix this? (and I'm assuming future versions of PowerMag will remedy it as well) I see no other way to add the header code save to manually edit my header.php file (which is undesirable)
  •  93
    djwd replied

    Hi there,

    The majority of scripts with a few exceptions should be loaded in footer for performance reasons, hence the decision. You can load scripts in header by adding something like this in functions.php (e.g. after line 317)

    wp_enqueue_script( 'scriptname', get_template_directory_uri() . '/js/yourscript.js', array( 'jquery' ), '2.1');

    I'll consider adding a textarea to load JS back in header though. 

    djwd

    Regards
    djwd

  • Clint replied

    One big one is Google DFP code, which is required to appear before the banner. There doesn't seem to be any way to add code into the header without a plugin or a template modification. That kills all banners. I can make it work by changing the templates, but even your description of the "Custom Javascript" field indicates that it woudl insert into the header, not the footer. 

    Food for thought.

  •  93
    djwd replied

    After the "Performance update (1.2)" all scripts outputs have been moved in footer, I forgot to change the description honestly. By the way you surely have a point, I will add a textarea to output scripts in header too in next update, in the meantime you can load the scripts in header manually while waiting for the update.

    Thanks for your feedback

    djwd

    Regards
    djwd

  •   Clint replied privately