0

When adding js file via wp_enqueue_scripts it's placed it in the <head> tag in the html source.

But in the DOM (F12) it's placed in the <body>. What can be the reason?

This is my page

<!DOCTYPE html>
<html>
    <head>
        <title>PAGE</title>
        <link rel="stylesheet" id="query-monitor-css"  href="https://www.sukkah2go.kipa.co.il/wp-content/plugins/query-monitor/assets/query-monitor.css?ver=1478770264" type="text/css" media="all" />
        <link rel="stylesheet" id="font-awesome-css"  href="https://www.sukkah2go.kipa.co.il/wp-content/plugins/wipi-builder/css/font-awesome.min.css?ver=4.6.3" type="text/css" media="all" />
        <link rel="stylesheet" id="mono-social-icons-css"  href="https://www.sukkah2go.kipa.co.il/wp-content/themes/wipi/css/mono-social-icons.css?ver=1.2.1" type="text/css" media="all" />
        <link rel="stylesheet" id="hebrew-fonts-css"  href="https://www.sukkah2go.kipa.co.il/wp-content/themes/wipi/css/hebrew-fonts.css?ver=1.2.1" type="text/css" media="all" />
        <link rel="stylesheet" id="jquery-magnificpopup-css"  href="https://www.sukkah2go.kipa.co.il/wp-content/plugins/wipi-builder/css/jquery.magnificpopup.css?ver=1.2.1" type="text/css" media="all" />
        <link rel="stylesheet" id="wipi-css"  href="https://www.sukkah2go.kipa.co.il/wp-content/uploads/wipi/skin-57f534186c4d2.css?ver=4.6.1" type="text/css" media="all" />
        <link rel="stylesheet" id="wipi-rtl-css"  href="https://www.sukkah2go.kipa.co.il/wp-content/themes/wipi/css/rtl.css?ver=4.6.1" type="text/css" media="all" />
    </head>

    <body>

    </body>
</html>
3
  • I think it's probably invalid HTML. When you do view source, you get the raw HTML from the server. When you use your dev tools (F12), you get output that is parsed by your browser and it will try to fix any problems with the HTML. Commented Nov 16, 2016 at 19:00
  • I recommend using a validator to validate your theme's raw html to find the problem. You can use this: validator.w3.org Commented Nov 16, 2016 at 19:01
  • 1
    For wordpress I think you should have <?php wp_head(); ?> inside your <head> section. That is how wp_enqueue_scripts works. Do you have this? Commented Nov 16, 2016 at 19:07

1 Answer 1

1

Take a look at code reference: https://developer.wordpress.org/reference/functions/wp_enqueue_script/

as you can see, last param of boolean type, and if set to true, it will output script file in body of document, not in head. Maybe that is problem.

wp_enqueue_script( string $handle, string $src = false, array $deps = array(), string|bool|null $ver = false, bool $in_footer = false )
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.