Optimize JS in MovableType

Everyone knows my blog is powered by MovableType. Actually I start to blog from MovableType 3.11.
There is a mt.js file in root of the blog. It is 20K after generating by MovableType 4.26.
Then to make it smaller. I use Yuicompressor which is provided by Yahoo Developer Network.
Then it is only 13K. And also I use gzip compress facility on Apache server. It is 4.1k when transferring to Web Browser.
Actually before minifiy its gzip size is 5.8K.
So it is clear to make a list.
Original mt.js
20.2K, gzip version 5.8K
Minified mt.js
13.1K, gzip version 4.1K

It is another trick to optimize JS files. Especially when more than 2 js files have to be included in blog.
I combined all js files into one js file. Don’t ask me how to combine it. Because I use the stupid way to combine them, just copy and paste.
Say I have five js files. Total 39K. After gzip, it is about 19K. When web page request them, five http request send out.
I put all js into one file, then only one http request needed.
And also I use minify tool to make it smaller.
After that, it is 30.5K, and gzip 14.6K. About 25% smaller.
OK I almost forget to mention one thing. To keep your mt.js minified version. Change mt.js publish to manually.

Leave a Reply

Your email address will not be published. Required fields are marked *