WordPress.org

Ready to get started?Download WordPress

Forums

Hueman
Move all JS to bottom and all CSS to TOP (4 posts)

  1. marjanstojanov
    Member
    Posted 3 months ago #

    Hello.
    Your theme is great. I really like it for my purpose but i'm wondering how can i move all CSS to top loading and all JS to load on the bottom of the page ?

  2. Alexander Agnarson
    Member
    Theme Author

    Posted 3 months ago #

    Hi! Thank you.

    The theme CSS should be loading in the head of the theme, you can see the enqueued css files in functions.php.

    As for the javascript, it's a good idea to load flexslider.js in head for optimal loading speed. All the other theme javascript is loaded in the footer.

  3. marjanstojanov
    Member
    Posted 3 months ago #

    Hello Alexander.

    Thanks for the reply.

    Yes all my CSS are loaded in the head section but also i dont want to use the slider the slider is currently disabled and i dont wanna load the flexslider.js.

    In the head i also have 3 js loading.

    wp-includes/js/jquery/jquery.js
    wp-includes/js/jquery/jquery-migrate.min.js
    wp-content/themes/hueman/js/jquery.flexslider.min.js

    I'm not sure does the js are from the theme ?

    So is there any chance to get rid of the slider and to load the jquery.js and jquery-migrate.min.js in the footer ?

    Thanks

  4. Alexander Agnarson
    Member
    Theme Author

    Posted 3 months ago #

    In functions.php, flexslider is loaded with:

    wp_enqueue_script( 'flexslider', get_template_directory_uri() . '/js/jquery.flexslider.min.js', array( 'jquery' ),'', false );

    You'd remove that by copying over the alx_script function to a child theme and remove that line. See more in theme options > help dropdown in the "child theme" section to see how to do.

    As for the jquery, that is loaded with WordPress standard functionality so I'm not quite sure how to move that down below. It is usually recommended to keep it up top as it needs to load first of the js scripts.

Reply

You must log in to post.

About this Theme

About this Topic