Tagged: jQuery, performance
-
AuthorPosts
-
February 17, 2017 at 2:26 pm #748444
Hi,
I have a small enhancement request.
I recently tried to move jQuery from header into footer of my website (running Enfold theme). Unfortunately, this turned out to be impossible, because Enfold theme registers avia-compat.js script in header with jQuery as dependency:
wp_enqueue_script( 'avia-compat', $template_url.'/js/avia-compat.js', array('jquery'), 2, false ); //needs to be loaded at the top to prevent bugs
I had a look on the avia-compat.js script and there is no line of code in it that utilizes jQuery. It would be perfect, if you could drop the dependency requirement in next version:
wp_enqueue_script( 'avia-compat', $template_url.'/js/avia-compat.js', array(), 2, false ); //needs to be loaded at the top to prevent bugs
The avia-compat.js would still be included in header, but jQuery could be included in footer with all the other scripts.Thanks in advance!
Greetings,
ČeslavFebruary 17, 2017 at 2:42 pm #748456Hi again,
I have one more enhancement request :) Currently, Enfold enqueues comment-reply.min.js script even on pages that have comments disabled, because the if-condition is incomplete:
if ( is_singular() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); }
The if-condition should also include
comments_open()
check – see the corresponding code in TwentySeventeen for example: https://github.com/WordPress/twentyseventeen/blob/master/functions.php#L313-L315 This way, the script will not be unnecessarily loaded on pages/posts with comments disabled.Cheers,
ČeslavFebruary 22, 2017 at 8:06 am #750306Hi!
Thank you for using Enfold.
You can use the “wp_dequeue_script” script to drop the script and then enqueue it again without the dependency but I’m not sure how it will turn out.
// https://codex.wordpress.org/Function_Reference/wp_dequeue_script
Example:
You need to adjust the values. For feature request, please visit the following link.
// https://kriesi.at/support/enfold-feature-requests/
Regards,
IsmaelFebruary 22, 2017 at 10:48 am #750381Hi Ismael,
Thanks for reply! I have edited the theme directly for now. I’ll submit these two as feature requests then and will hope that they’ll get included :) If not, I’ll resort to script re-queueing.
Cheers,
ČeslavFebruary 23, 2017 at 6:16 am #750820Hi Česlav,
Great, thanks for the feedback. Please let us know if you should need any further help on the topic or if we can close it.
Best regards,
RikardFebruary 23, 2017 at 10:38 am #750879Hi Rikard, yes, you can close this topic!
February 24, 2017 at 4:41 am #751211 -
AuthorPosts
- You must be logged in to reply to this topic.