WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Live Comment Preview] Caching the JS script (4 posts)

  1. Fernando Serer
    Member
    Posted 6 years ago #

    Hi! and congratulations for this plugin!

    I'm caching in client side all static files as JS scripts for server performance and better user experience.

    I would like to know if you are considering (or it's possible) to include the JS script for your plugin in a 'regular' cacheable way like:

    myserver.com/wp-content/plugins/live-comment-preview/live-comment-preview.js

    instead of:
    myserver.com/?live-comment-preview.js

    could save 13KB's on every page load (or 4 KB if gzipped)

    also including the version number as many other plugins do is a good idea as it will invalidate the client side cached version:

    server.com/wp-content/plugins/live-comment-preview/live-comment-preview.js?ver=1.9

    best regards

    Fernando

  2. Lester Chan
    Member
    Posted 6 years ago #

    It can be packed using http://dean.edwards.name/packer/

  3. monodistortion
    Member
    Posted 6 years ago #

    The javascript for this plugin is a little tricky because it is generated dynamically and customized by a function in live-comment-preview.php. That's why it's called with the query ?live-comment-preview.js. I was looking into forcing it to cache in the browser but I think that may break the way the gravatar IDs are generated dynamically. Making the entire javascript static looked like a lot more hacking than I was willing to try.

    I was able to generate a gzipped file by changing line 72 from:

    header('Content-type: text/javascript');

    to:

    ob_start ("ob_gzhandler"); //compress with gzip if possible
    header('Content-type: text/javascript');

    This reduces the javascript file size from 13.4KB to 4.4KB.

  4. monodistortion
    Member
    Posted 6 years ago #

    Oh, as a side note, the md5.js file can be minified to save a few K. I was just doing some research and this site looks interesting:
    http://compressorrater.thruhere.net/

    You can compare the compression of four different javascript compressors (before and after gzip).

Topic Closed

This topic has been closed to new replies.

About this Topic