• Hello! Why might the error “ReferenceError: jQuery is not defined” appear? The line is “jQuery (document) .ready (function ($)”.

    <script >              
    jQuery(document).ready( function($) {    
        if ($('#adsforwp-hidden-block').length == 0 ) {
        $.getScript("https://site.ru/front.js");
        }
                     
    });
    </script>

    And another question, if I connect the ad code only for AMP pages or only on certain pages, how can I remove the plugin script output on all other pages where there are no ad units ?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Natalya

    (@nalitana)

    Hello again! I understood why the error, because all the scripts in the subject are connected in the footer. Is there any way to transfer this script to the footer as well? Thank!

    Plugin Author Magazine3

    (@magazine3)

    Can you share the URL so that I can see where the code loads and the reason for it?

    So that I can understand and help you.

    Thread Starter Natalya

    (@nalitana)

    Hello! Have a nice day! The reason is that the connection of all scripts, including jquery.js, has been transferred to the footer. A plugin script is connected before jquery.

    function remove_head_scripts() {
    remove_action('wp_head', 'wp_print_scripts');
    remove_action('wp_head', 'wp_print_head_scripts', 9);
    remove_action('wp_head', 'wp_enqueue_scripts', 1);
    
    add_action('wp_footer', 'wp_print_scripts', 5);
    add_action('wp_footer', 'wp_enqueue_scripts', 5);
    add_action('wp_footer', 'wp_print_head_scripts', 5);
    }
    add_action( 'wp_enqueue_scripts', 'remove_head_scripts' );
    Plugin Author Magazine3

    (@magazine3)

    So you want to move the .js file to the footer, right?

    Which file of ours do you want to move to footer?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘ReferenceError’ is closed to new replies.