WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
Defer JavaScript Parsing (25 posts)

  1. Dusibello
    Member
    Posted 2 years ago #

    Absolutely brilliant work on this plugin. Has done WONDERS for my Google Page Speed rating.

    One issue GPS recommends work on is the following: Defer parsing JavaScript to reduce blocking of page rendering.

    Not sure of where and how to do that in W3TC settings.

    http://wordpress.org/extend/plugins/w3-total-cache/

  2. Pothi
    Member
    Posted 2 years ago #

    There is no W3TC settings to do this.

    There are a lot of tips available to do it manually when I searched the term "Defer parsing JavaScript to reduce blocking of page rendering" in Google.

  3. Dusibello
    Member
    Posted 2 years ago #

    Thanks Pothi - Yeah, before trying all those 'manual' options I wanted to be sure I was not missing a setting in W3TC.

    Cheers

  4. Frederick Townes
    Member
    Plugin Author

    Posted 2 years ago #

    Additional options for this will come in a later release.

  5. southcast
    Member
    Posted 2 years ago #

    Sorry to piggyback this thread. I saw no point in creating another thread on the same topic. No spamming intended.

    Dear Frederick, I have implemented your plugin on my site and it works awesome. I am using the latest version 0.9.2.4. I noticed that this thread is about 4 months ago, so i was just wondering if you might have already added the "defer the parsing of javascript" feature and if it hidden somewhere in the setting options coz I couldn't find it. I checked the other tuts available on the web but some seemed risky and some are unnecessarily complicated.

    P.S - Really thankful to you for such an efficient plugin. I have referring many people in my threads to use it.

  6. Pothi
    Member
    Posted 2 years ago #

    i was just wondering if you might have already added the "defer the parsing of javascript" feature and if it hidden somewhere in the setting options coz I couldn't find it.

    @southcast This feature is not added yet.

  7. southcast
    Member
    Posted 2 years ago #

    Dear Pothi, very kind of you to give a feedback. I was suggested this code by someone in one of the non-wordpress forums. Code to be added
    just before the end body tag.

    <script defer="defer" type="text/javascript">
        window.onload=function(){
            var mycode;
            mycode=document.createElement("script");
            mycode.type="text/javascript";
            mycode.src="http://www.example.com/path/yourjavascriptfile.js";
            document.getElementsByTagName("head")[0].appendChild(mycode);
        }
    </script>

    I have put this code in my footer template as suggested and it seems to work but I am not very sure if that is the right place or the code is compatible to other browsers too. Please correct me if I am wrong. It helped to increase my page speed a bit though. Just asking to be sure about it. Will appreciate your response.

    P.S - As the code has helped me a bit so I wanted to leave it here so others looking for an alternative could try this too.

    Cheers.

  8. Pothi
    Member
    Posted 2 years ago #

    I'm not too much into JS. I'm sorry. That's why I'm looking forward to the next version of W3 Total Cache plugin too. :)

  9. a4jp.com
    Member
    Posted 2 years ago #

    I need the defer option as well for JavaScript. My page is so slow even using your plugin.

  10. a4jp.com
    Member
    Posted 2 years ago #

    I also get a message saying: The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources.

    Could you also make your plugin set the expiration date for images?

  11. southcast
    Member
    Posted 2 years ago #

    I will share my observations which is currently working great for me. I will mention it here so that the others looking for similar alternatives could possibly make use of this. As of now my settings seem to be working great on chrome, IE9 latest and FF latest.

    Firstly, there is a setting actually in W3Total using which we can minify a javascript. For this to work go to Performance - General settings - Minify - and Enable. Then go to Performance - Minify - JS - JS file management - and add whatever js files you want to. However, this method did not work for me as some of my scripts did not seem to work while minified. I have mentioned it here nonetheless, just because there is such option available.. if someone wants to try. It may work for others if not for me.

    Secondly, I use FB-likebox, like button and Gplus like button and I noticed that these social plugins are the major contributors in pulling down my GPS {Google page speed ) and Yslow scores. But then thankfully i discovered that google and facebook both provide asynchronous code for lazy loading. So i went ahead and made use of that and It made a massive difference in my scores.
    I have used this asynchronous scripts as following in the footer just above the </body>.

    Since the forum rules does not allow more than ten lines of code, I had to put it in pastebin. You can find the complete code in pastebin, that which I currently use on my site.

    For the facebook script to work you may want to put the following declaration into the header.

    <xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/">

    Now all you need to do is paste the following appropriate codes to your template wherever you want the buttons or boxes to render.

    G-PLUS :

    <div class="g"><div class="g-plusone" data-size="medium"></div>

    FB :

    <fb:like href="http://southcast.in/" layout="button_count" show_faces="false" width="100" height="21" action="like" colorscheme="light" font="trebuchet ms" allowTransparency="true"></fb:like>

    I am no expert coder or anything but after applying these codes my scores are pretty good now as I also use other online tools to assess my site's performance.

    P.S - Do not forget to clean your cache one you have made the changes to see the results in the frontend. You may also want to test the changes in different environments because every browser uses unique parsing and rendering parameters.

  12. Frederick Townes
    Member
    Plugin Author

    Posted 1 year ago #

    If you guys email me I can send you the next release with support for this option.

  13. a4jp.com
    Member
    Posted 1 year ago #

    I want it ^^. Are you the original developer?

  14. floriz
    Member
    Posted 1 year ago #

    Hi Frederick. Can ypu please send me the next release i would love to have this feature! Thanks!

  15. ichpen
    Member
    Posted 1 year ago #

    I'd love a pre-release copy also. ichpen[at]gmail.com

    Thanks Frederick.

  16. leownn
    Member
    Posted 1 year ago #

    I want it please :D tendenciaselegantes gmail.com ur hotmail

  17. ravb
    Member
    Posted 1 year ago #

    I too am interested in this "deferring" option (can't find your e-mail address though).

    Just one question: when I want to defer some js files, but not all and I still want to combine all the files and place them in the footer; will there be two combined js files?

  18. Conseil-en-organisation
    Member
    Posted 1 year ago #

    Hi Frederik,
    Could you email me the last release wih the defer option please.
    Thanks.

  19. a4jp.com
    Member
    Posted 1 year ago #

    When will the plugin get a standard update with the defer option? Or is that only given to people as an option?

  20. louises
    Member
    Posted 1 year ago #

    Is there somewhere you can fetch this new version with defering option?

  21. dentvii
    Member
    Posted 1 year ago #

    I would also love to test the w3tc with defering. Townes, could you provide a link so we won't bother on your email?

  22. melashcott
    Member
    Posted 1 year ago #

    Hi Frederick - love your work! Yes please if you have the time to email to me as well.. thank you so much for all your effort. Here's a link to my website, that goes ok in PageSpeed - but deffering the js parsing will help some more...
    http://www.weddingphotographymelbourne.com.au

  23. daverage
    Member
    Posted 1 year ago #

    Hi.

    I was wondering if anyone ever got a copy of W3TC with javascript defer built in?

    Thanks

  24. gr8job
    Member
    Posted 1 year ago #

    Hi Frederick,

    Is the upgrade to W3TC available yet ? I just installed your excellent plugin and it raised my speed on webpagetest from 66/100 to 77/100 in the first pass.

    I have some issues with:
    1. Leverage Browser Caching
    2. Combine images into CSS sprites
    3. Defer Parsing of Javascript

    I understand the upgrade mentioned in this thread will address number 3 above, but one of the three JS files mentioned is http://....../wp-content/w3tc/min/a62d3/index.include.9fc1ab.js which looks like a w3tc JS. Does it make sense to defer parsing of this file ?

    Could you please advise when the upgrade will be available, and can you give me any tips on items 1 and 2 above ?

    Many thanks

  25. jcapdepuy
    Member
    Posted 1 year ago #

    Hello, waiting the solution by the plugin I propose you this solution :
    http://wpengineer.com/2482/enqueue-bundled-jquery-in-footer/

    This solution move the javascript files on the footer, so it's not The solution for a good total parsing but that's already a solution ;)

    For example on my website after this manipulation, GTMetrix is almost OK with me :)

    All you have to do it's :
    -> go to wp-includes/script-loader.php
    -> go to the bottom of the file and add the solution proposed by the author of the article :

    replacing 'add_action( 'wp_default_scripts'.....' line's

    by :

    function ds_enqueue_jquery_in_footer( &$scripts ) {

    if ( ! is_admin() )
    $scripts->add_data( 'jquery', 'group', 1 );
    }
    add_action( 'wp_default_scripts', 'ds_enqueue_jquery_in_footer' );

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic