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

  1. marjanstojanov
    Posted 1 year ago #

    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
    Posted 1 year 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
    Posted 1 year 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.


    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 ?


  4. Alexander Agnarson
    Posted 1 year 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.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic