user186585
user186585

Reputation: 512

Adding script via wordpress wp_enqueue_scripts in the <head>

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>

Upvotes: 0

Views: 54

Answers (1)

Nikola Kirincic
Nikola Kirincic

Reputation: 3757

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 )

Upvotes: 1

Related Questions