WordPress header.php使用错误的Jquery代码保留旧的已删除的<script>标记。 (没有启用缓存)

i have the following problem on this website: http://client1.studdo-media.nl/

when i open the dev tools for Chrome i see the following JS errors:

client1.studdo-media.nl/:8 Uncaught ReferenceError: $ is not defined
client1.studdo-media.nl/:23 Uncaught ReferenceError: $ is not defined
client1.studdo-media.nl/:47 Uncaught ReferenceError: $ is not defined

I know WordPress needs a noConflict Wrapper for JQuery to work with $.

I removed the wrong code in the header.php file and replaced it with correct, wrapped JQuery, and placed it in the body to make sure JQuery is loaded.

This is my header.php file right now

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">


<?php wp_head(); ?> 
</head>

    <body <?php body_class('blog-page'); ?>>
        <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="/wp-content/themes/mercurius/assets/css/jquery.fullPage.css" />
<script type="text/javascript" src="/wp-content/themes/mercurius/assets/js/jquery.fullPage.js"></script>  

<script>
jQuery( document ).ready( function( $ ) {
        $('a[href*=#]:not([href=#])').click(function() {
            var target = $(this.hash);
            target = target.length ? target : $('[name=' + this.hash.substr(1) +']');
            if (target.length) {
                $('html,body').animate({
                  scrollTop: target.offset().top
                }, 1500);
                return false;
            }
        });
        });
</script>
<script>
jQuery( document ).ready( function( $ ) {

    $('#someID').click(function(){
        $('html, body').animate({scrollTop:$(document).height()}, 'slow');
        return false;
    });

});
</script>
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-81168606-1', 'auto');
  ga('send', 'pageview');
</script>

<!-- parallax header -->
<script>
  jQuery(window).scroll(function() {
    var scroll = jQuery(window).scrollTop();            
    jQuery(".carousel .fill").css("transform","translateY(" +  (scroll)/2  + "px)");
  });
</script>

    <!-- Header Section -->
    <header id="header"> 

note: everything under header opening tag is not relevant for this question and therefore not pasted here.

The correct code is loaded by WordPress right after the open tag.

I cant seem to find out why the old (wrong) code is still loaded into my website. Note:the wrong code seems to be added before the

<!DOCTYPE html>

see this image: wordpress script tag before

I have no caching enabled.

Edit: the scripts tags were loaded by another file in my themes folder, so it has not much to do with header.php.. (answer by lassemt)

I don't have 50 reputation yet, so I couldn't comment this.. But I will try to explain to you whats wrong with the scripts.

First, wordpress doesn't need noConflict wrapper unless it is jquery in backend (in the adminpanel).

The problem is basically "cascading". Inspecting your code I noticed you have the same scripts loaded right after the head inside the head (they are duplicate). The reason you get these error messages is because the website are trying to run functions requiring jQuery before jQuery is loaded in your document.

If you inspect your site and check inside the tag right after where google analytics are loaded you will see you have 3 different inline scripts loaded. The first e are scripts using jquery and are duplicate.

It can look like these scripts come with wp_head() by looking at the code you shared with us, so maybe they are still in the functions.php?

Edit with solution after checking out the theme

In your theme if you look at the inc/includes/head.php file, you will see thats the file where the unwanted code is. This file is being included with the inc/init.php (it uses a function that includes all the files in the "includes" folder). Solution is to edit the head.php file and remove the scripts from it or just delete the file.

It's likely that another plugin or script or function is attached to a word-press hook (https://codex.wordpress.org/Plugin_API/Action_Reference) which is outputting data before the header.php file is loaded. Try disabling all plugins, and re-enabling one at a time until you find the error. This could also happen if any code was placed in any of the wordpress core files such as functions.php file or the like, rather then in the header.