Hallo,
Jquery wird ja bei Wordpress standardmäßig im <head> geladen. Aus Performance-Gründen möchte ich es jedoch im Footer laden. Hat das schon jemand erfolgreich umsetzen können? Habe hierzu folgenden Code in die functions.php eingefügt. Das Script wird jedoch weiter im Header geladen. Nutze Wordpress 4.0
PHP
function my_init()
{
if (!is_admin())
{
wp_deregister_script('jquery');
// Load the copy of jQuery that comes with WordPress
// The last parameter set to TRUE states that it should be loaded
// in the footer.
wp_register_script('jquery', '/wp-includes/js/jquery/jquery.js', FALSE, '1.11.0', TRUE);
wp_enqueue_script('jquery');
}
}
add_action('init', 'my_init');
Alles anzeigen