-
AuthorPosts
-
February 21st, 2013 at 15:45 #3771Tche
Hello guys (and ladies),
First of all a big thank you for this great customizable theme!
I am adapting it further with a child theme and I d like to move JS scripts to the footer to make the website load faster. I ve found this code to do so:
<code>// Move All Javascript to Footer
<?php
remove_action(
'wp_head'
,
'wp_print_scripts'
);
remove_action(
'wp_head'
,
'wp_print_head_scripts'
, 9);
remove_action(
'wp_head'
,
'wp_enqueue_scripts'
, 1);
add_action(
'wp_footer'
,
'wp_print_scripts'
, 5);
add_action(
'wp_footer'
,
'wp_enqueue_scripts'
, 5);
add_action(
'wp_footer'
,
'wp_print_head_scripts'
, 5);
?>
</code>
But as mentionned in functions.php I shouldn’t change anything in it… As it refers to other functions.php files I wonder if I could adapt these?
And if it’s the case in which one I could set this code… (theme-functions.php?)?
I have been looking for documentation about these without finding it. In fact being up to adapt them could avoid the use of too many plugins.
Many thanks in advance for your help!
Have a nice day!
Tche
February 21st, 2013 at 18:41 #3774ZedCryout Creations mastermindYou should put all your code into the child theme’s functions.php file.
Note that (as I have found out the hard way) not all actions are removed properly by just using remove_action(). Also, note that Mantra has more hook functions than the ones listed in your sample code.
The safest way is to use a wrapper function:
function remove_mantra_functions() {
remove_action(...);
// insert all your remove_action calls here
}
add_action('init','remove_mantra_functions');then use add_action() to attach your child theme function replacements.
If you like our creations, help us share by rating them on WordPress.org.
Please check the available documentation and search the forums before starting a topic. -
AuthorPosts
The topic ‘Move JS in the footer // Adapt functions.php’ is closed to new replies.