Tagged: enfold, http requests, javascript, jQuery, merge, performace
Hi,
currently jQuerry, my own JavaScript (main-child.js) and avia-footer-scripts… .js are called by seperate HTTP-requests.
(at least, that is what I see in my Chrome network tab)
Here is how I load my custom JS from my childs functions.php
function custom_scripts(){
?>
<script type='text/javascript' src="./wp-content/themes/enfold-child-fecgz/js/main-child.min.js" defer='defer'></script>
<?php
}
add_action('wp_footer', 'custom_scripts');
My two questions are:
1. Is it possible to combine all three js files into one?
I could just paste the jQuery code into my custom,js for example.
Then it just needs to be merged with the other js fie from the theme.
2 Is jQuery really needed for the theme or can it be removed if I will do without some functions of the theme?
Here is what I found (unfortunately without help from the support-team).
You can merge your own custom.js files with the merging-files option from enfold.
See: https://kriesi.at/support/topic/add-own-script-js-file-to-avia-footer-scripts-js/#post-1048707
It seems to not be possible to add the jQuerry.js file into it that simple (the backend admin-section also uses it for example). Maybe someone has a good solution for it?
Is it possible to merge the files, only when no admin-user is logged in, and just the page is served to the user?
Hi fecgz,
The files are merged when you make a chang in css, save the theme options. They are served merged form the server until you make a new change or save theme options.
If you need further assistance please let us know.
Best regards,
Victoria