Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter charlietech

    (@charlietech)

    Thanks for the response, could you elaborate a little about conditional tags? i didnt see anything that had to do with code above

    for example:

    if( is_front_page() ){
        wp_enqueue_script('global', 'https://www.xertionfitness.com/.../global.js');
    }

    More examples:
    Load script in header

    function load_header_scripts(){
         wp_enqueue_script('global', 'https://www.xertionfitness.com/.../global.js');
    }
    add_action('init', 'load_header_scripts');

    Load script in footer

    function load_footer_scripts(){
        wp_enqueue_script('global', 'https://www.xertionfitness.com/.../global.js', false, false, true);
    }
    add_action('init', 'load_footer_scripts')

    Both of these will be loaded at the same time on the server, but on the front end will be loaded at different times in the browser.

    Thread Starter charlietech

    (@charlietech)

    Thanks you so much, i kinda understand now. Can you answer this for me, Whats the difference if i use the format above or if i use w3tc and minify the code manaully in the js section? Why do the code above work better? just curious. Where do i put the code? in header, function, index php?

    To add more code to function I just

    function load_footer_scripts(){
    wp_enqueue_script(‘global’, ‘https://www.xertionfitness.com/…/global.js’, false, false, true);
    wp_enqueue_script(‘global’, ‘https://www.xertionfitness.com/…/s2member-o.php?);
    }
    add_action(‘init’, ‘load_footer_scripts’)

    Thread Starter charlietech

    (@charlietech)

    In the footer example, what is the false, false, true about?You didnt put it in the other codes?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to choose defer parsing javascript’ is closed to new replies.