WordPress.org

Ready to get started?Download WordPress

Forums

How to choose defer parsing javascript (7 posts)

  1. charlietech
    Member
    Posted 1 year ago #

    I have these codes that pagespeed say can be defer parsing, when i try to use w3tc to minify them, it seem to slow my site down. My question is how to tell which ones can be defer? Is there a formula to use?

    http://cdn.xertionfitness.com/.../jquery.js?... (86KiB)
    http://www.xertionfitness.com/.../global.js (27.8KiB)
    http://cdn.xertionfitness.com/.../suffusion.js?... (20.3KiB)
    http://www.xertionfitness.com/.../fileuploader.js?... (18.4KiB)
    http://www.xertionfitness.com/.../s2member-o.php?... (14.1KiB)
    http://cdn.xertionfitness.com/.../thickbox.js?... (6.6KiB)
    http://www.xertionfitness.com/.../bpfb_interface.js?... (6.3KiB)

  2. cynnie88
    Member
    Posted 1 year ago #

  3. charlietech
    Member
    Posted 1 year ago #

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

  4. cynnie88
    Member
    Posted 1 year ago #

    for example:

    if( is_front_page() ){
        wp_enqueue_script('global', 'http://www.xertionfitness.com/.../global.js');
    }
  5. cynnie88
    Member
    Posted 1 year ago #

    More examples:
    Load script in header

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

    Load script in footer

    function load_footer_scripts(){
        wp_enqueue_script('global', 'http://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.

  6. charlietech
    Member
    Posted 1 year ago #

    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', 'http://www.xertionfitness.com/.../global.js', false, false, true);
    wp_enqueue_script('global', 'http://www.xertionfitness.com/.../s2member-o.php?);
    }
    add_action('init', 'load_footer_scripts')

  7. charlietech
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.