Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter perleone

    (@perleone)

    Problem solved.

    It occured because of the ‘defer’ in the script tag. This was caused by the Plugin
    Async JavaScript. It was possible to exclude jQuery.js from the Async Plugin an then everything worked fine.

    Maybe this can help someone in the future.
    Thanks anyway

    perleone

    Thread Starter perleone

    (@perleone)

    I solved the Problem but just in a deprecitated way. The trouble is caused by the jQuery Error. But I am not able to enqueue jQuery via

    add_action( 'wp_print_scripts', 'add_my_scripts', 100 );
    function add_my_scripts() {
    if ( !is_admin() ) {
    wp_deregister_script( 'jquery' );
    wp_register_script( 'jquery', ( 'https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js' ), false, null, true );
    wp_enqueue_script( 'jquery' );
    } }
    add_action('init', 'add_my_scripts');

    or

    add_action( 'wp_print_scripts', 'add_my_scripts', 100 );
    function add_my_scripts() {
    if ( !is_admin() ) {
    wp_deregister_script( 'jquery' );
    wp_register_script( 'jquery', ( 'https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js' ), false, null, false );
    wp_enqueue_script( 'jquery' );
    } }
    add_action('init', 'add_my_scripts');

    when I look at my sourcecode I can see jQuery is embedded in the head, like in the codeblock

    <script type='text/javascript' defer='defer' src='https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js'></script>

    but I run into the same jQuery Issue anyway.

    Only when I insert my jQuery through the header.php, like its not recommended I solved my Problem, no Errors, FavoritePosts works.

    But I want to do it the right way, Can anyone help me please

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)