I found out that wpml force my jquery to load into header. (I already deregistered it and registered my own one).
Is there a way to move wpml script in footer?
I found out that wpml force my jquery to load into header. (I already deregistered it and registered my own one).
Is there a way to move wpml script in footer?
Share Improve this question asked Nov 4, 2016 at 9:38 MarcoMarco 1134 bronze badges 3- wpml/forums/topic/how-to-load-wpml-scripts-in-footer – Rishabh Commented Nov 4, 2016 at 9:47
- first result on google, already read. I asked here because maybe I need more infos or maybe I'd like to find different approach? – Marco Commented Nov 4, 2016 at 9:59
- Yep! I deregister jquery, register it again with footer option 'true', but when I activate wpml main plugin, it forces jquery (and jquery ui) in the header. I'm going to search for wpml register script function, get scripts handles, deregister them in my theme and register them again with footer option. – Marco Commented Nov 4, 2016 at 17:18
1 Answer
Reset to default 0It depends. As commented on OP, WPML documentation and support are very minimal on this front.
I found that for me, the only culprit forcing jQuery to the head of the HTML was wpml-xdomain-data.js
from sitepress-multilingual-cms/classes/url-handling/class-wpml-xdomain-data-parser.php:53
. This script appears to handle some part of the language switchers and, as I have a custom language switcher, I could deregister this script without loss of functionality:
wp_deregister_script('wpml-xdomain-data');
In functions.php
through wp_enqueue_scripts
hook.
Also see: https://wpml/forums/topic/how-to-load-browser-redirect-js-and-jquery-cookie-js-in-the-footer/