Not able to integrate Jquery CDN with my website
-
Hi Everyone,
I was trying to change the static JQuery File to using CDN. I have inserted these lines of code and I researched a lot before inserting this code:
add_action( 'wp_enqueue_scripts', 'jquery_bind' ); function jquery_bind() { // instead of "jquery-core" just "jquery", to disable jquery-migrate wp_deregister_script( 'jquery-core-js' ); wp_register_script( 'jquery-core', 'https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js',false); wp_enqueue_script( 'jquery' ); } add_action( 'wp_enqueue_scripts', 'jquery_migrate_bind' ); function jquery_migrate_bind() { // instead of "jquery-core" just "jquery", to disable jquery-migrate wp_deregister_script( 'jquery-migrate-js' ); wp_register_script( 'jquery-core', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-migrate/3.4.0/jquery-migrate.min.js',false); wp_enqueue_script( 'jquery' ); }
The problem is still the same and now my console is full of errors. My head tag still has the <script> tag for the static jquery file on my server. Can anyone tell me how can I use the CDN with my WordPress website?
Console Error:
Failed to load resource: the server responded with a status of 404 ()
(jquery.min.js:1)Failed to load resource: the server responded with a status of 404 ()
(jquery-migrate.min.js:1)I am using WP Super Cache.
Thanks,
KavyeshThe page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Not able to integrate Jquery CDN with my website’ is closed to new replies.