Ok, i've tried all day long and do not know, how this can be. I have a website on which i load jquery like that:
function my_script_loader() {
if (!is_admin()) { // only load for front end
//Clear jQuery if already registered
wp_deregister_script('jquery');
wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js", array(), '1.11.1', '',true);
wp_enqueue_script('jquery');
} // End of if statement
} // End of Function
add_action('wp_enqueue_scripts', 'my_script_loader');
The expected result in the Dom is:
<script type="text/javascript" defer="defer" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
Then i am doing the exact same thing on another website which is a subdomain:
function script_loader() {
if (!is_admin()) {
//Clear jQuery if already registered
wp_deregister_script('jquery');
wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js", array() , '1.12.4', '',true);
wp_enqueue_script('jquery');
}
} // End of Function
add_action('wp_enqueue_scripts', 'script_loader');
The unexpected result in the Dom is:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js?ver=1.12.4">
I have disabled plugins and removed all scripts but the script is not deferred. How can that happen? Thanks for your interest. theo