Title: [Plugin: Live Comment Preview] Caching the JS script
Last modified: August 19, 2016

---

# [Plugin: Live Comment Preview] Caching the JS script

 *  [Fernando Serer](https://wordpress.org/support/users/fserer/)
 * (@fserer)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/plugin-live-comment-preview-caching-the-js-script/)
 * 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

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Lester Chan](https://wordpress.org/support/users/gamerz/)
 * (@gamerz)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/plugin-live-comment-preview-caching-the-js-script/#post-811482)
 * It can be packed using [http://dean.edwards.name/packer/](http://dean.edwards.name/packer/)
 *  [monodistortion](https://wordpress.org/support/users/monodistortion/)
 * (@monodistortion)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/plugin-live-comment-preview-caching-the-js-script/#post-811985)
 * 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.
 *  [monodistortion](https://wordpress.org/support/users/monodistortion/)
 * (@monodistortion)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/plugin-live-comment-preview-caching-the-js-script/#post-811989)
 * 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/](http://compressorrater.thruhere.net/)
 * You can compare the compression of four different javascript compressors (before
   and after gzip).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[Plugin: Live Comment Preview] Caching the JS script’ is closed to new
replies.

 * 3 replies
 * 3 participants
 * Last reply from: [monodistortion](https://wordpress.org/support/users/monodistortion/)
 * Last activity: [17 years, 9 months ago](https://wordpress.org/support/topic/plugin-live-comment-preview-caching-the-js-script/#post-811989)
 * Status: not a support question

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
