Tagged: , , ,

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #19198

    It appears that for some reason enqueued scripts are being inserted in the middle of the body instead of head, which causes issues.

    What may be causing this and can this be fixed?



    Hey FarenAgency,

    Can we take a look at your site live? They should only be getting spit out at wp_head in the header.php file. Can you also try disabling all active plugins except for woocommerce and see if that fixes the issue?




    Hi Devin, thank you very much for quick reply.

    An example can be observed here: http://www.hiyorkdale.com/

    Disabling plugins didn’t help.



    Some javascripts are added into the footer section (before the closing body tag (I wouldn’t call this “in the middle” though)). It’s considered “best practice” to load/include the scripts at the end of the html document because it can speed up the loading process (including page generation & code execution) a bit. The wp_enqueue script function supports both locations (head or footer): http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Parameters (in_footer parameter).

    If you want to change the location of the theme scripts open up functions.php and replace:

    wp_register_script( 'avia-prettyPhoto',  AVIA_BASE_URL.'js/prettyPhoto/js/jquery.prettyPhoto.js', 'jquery', "3.0.1", true);
    wp_register_script( 'aviapoly-slider', AVIA_BASE_URL.'js/aviapoly2.js', 'jquery', "1.0.0", true);


    wp_register_script( 'avia-prettyPhoto',  AVIA_BASE_URL.'js/prettyPhoto/js/jquery.prettyPhoto.js', 'jquery', "3.0.1", false);
    wp_register_script( 'aviapoly-slider', AVIA_BASE_URL.'js/aviapoly2.js', 'jquery', "1.0.0", false);


    Thanks for the quick reply,

    The issue that I’m having is that I can not have jquery datepicker to work with your theme. I thought it had something to do with the way some script are included in footer, but it sees the problem is elsewhere.

    Here’s what I’m enqueuing:

    wp_enqueue_style(‘jquery-ui’, ‘http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css’);


    From what I understand, there is a conflict with prettyphoto used in the theme.

    I do not get any js errors, but the popup does not appear in your theme. It appears if i switch to a different theme though.

    Could you look into this please?


    The datepicker doesn’t support custom z-index values. If the theme (like Replete) changes the z-index for the content area the datepicker div will break. You need to add following code to css/custom.css or the quick css field to fix the issue:

    z-index: 99 !important;


    That worked. Thank you very much.


    Glad Dude could help :)

    Let us know if you have any other questions or issues.



Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Enqueued scripts inserted in the middle of the body’ is closed to new replies.