Y
Y
Yuri Yanin2018-02-07 11:53:58
JavaScript
Yuri Yanin, 2018-02-07 11:53:58

Why did jQuery scripts stop working in Wordpress after transfer to hosting?

Everything works fine on my server. I prepared the site for the transfer, but after the transfer, several scripts stopped working and in the console it gives the error
Uncaught TypeError: jQuery(...).lightSlider is not a function

There is a reaction to $ and jQuery in the console, which means jQuery is connected. On the server in the header, I connect the Google 3.1.1 library (something doesn’t work without it), I do the following manipulations through function php:
wp_deregister_script('jquery');
wp_register_script('jquery', (" https://ajax.googleapis.com/ajax/libs/jquery/1.12.... "), false, '1.12.4');
wp_enqueue_script('jquery');
What could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mike, 2018-02-07
@MikeKosulin

Remove upload from header

function vpank_replace_jquery() {
  wp_deregister_script('jquery');
  wp_enqueue_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array(), null, true);

}
add_action('wp_enqueue_scripts', 'vpank_replace_jquery');

V
Vladimir Druzhaev, 2018-02-07
@OtshelnikFm

According to the code, you need to connect jquery from the WordPress folder, and not from Google. So some plugin or script in the theme is in conflict giving you an error

bzz...
Ох уж эти оптимизаторы. Экономят на спичках - потом проблемы решают

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question