News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Kae Verens' Blog:
efficient JS minification using PHP
May 21, 2008 @ 10:25:35

In a new post today, Kae Verens takes a look at a method for easy and quick javascript minification with help from a little bit of PHP.

A useful part of minification is that during the act of compiling your minified source, you can also pull in other JavaScript files and compiled them all into one single source. This has a major advantage that there is only one file to download.

The method runs a file_get_contents on each of the javascript files, and pulls their content into a single PHP variable. This value is then just echoed out after it's passes through this minimizer class.

Kae also offers an alternative to performing this expensive operation each time - caching then checking the md5 hash of the cache to see if it's different than the current version. Example code is included.

0 comments voice your opinion now!
efficient minification filegetcontents caching javascript


blog comments powered by Disqus

Similar Posts

Pablo Viquez' Blog: How to use json_encode with ISO-8859-1 data – Part2

IBM developerWorks: Devise Web 2.0 applications with PHP and DHTML (Part 1)

Lorna Mitchell's Blog: Fetching Your Talks from the Joind.In API

Matt Curry's Blog: Check Out These Upgrades I Made To The CakePHP DebugKit

Job Posting: Emma Seeks PHP & Javascript Developer (Nashville, TN)


Community Events





Don't see your event here?
Let us know!


developer introduction podcast opinion deployment tips bugfix api threedevsandamaybe library list series community laravel symfony release interview framework zendserver language

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework