nukeSEO.com - PHPNuke SEO Search engine optimization, professional tools including nukeSEO, nukeSPAM, nukeFEED, nukePIE, nukeWYSIWYG and more

 

. Welcome to nukeSEO.com  ! 
.
.
.


.
. . .
 Speed up your site by optimizing your external JS and CSS 
.
.
Web Development

Webmasters and developers are using powerful Javascript (JS) libraries and Cascading Styles Sheets (CSS) to improve the online experience, functionality and appearance for their users.  Most of these additions are stored in external files that must be downloaded by the visitor's browser when first using the script. Modern browsers cache these files to improve performance, but according to Yahoo's research on caching, about half of users will never have the opportunity to cache the page contents.  The files themselves often contain comments and other source that don't affect the usefulness of the file, but slow down the initial load.  That's where minification can help.  Minification involves compressing files through various techniques, from simply removing blanks to shortening variable names and compressing the files (most modern browsers also have the ability to decompress on-the-fly).

We'll be including minified files in future nukeSEO products, but you can quickly optimize your existing JS and CSS files and speed up your website your own using online tools...  Read more to see the options currently available - including powerful online minification services!

There are several different minification algorithms, each with its own benefits:

Algorithm Vendor Description Online Tool PHP Port
Dojo ShrinkSafe Instead of relying on brittle regular expressions, ShrinkSafe is based on Rhino, a JavaScript interpreter. This allows ShrinkSafe to transform the source of a file with much more confidence that the resulting script will function identically to the file you uploaded. Best of all, ShrinkSafe will never change a public variable or API. That means that you can drop the compressed version of your JavaScript into your pages without changing the code that uses it. ShrinkSafe online n/a
JSMIN Removes comments and unnecessary whitespace from JavaScript files. It typically reduces filesize by half, resulting in faster downloads. It also encourages a more expressive programming style because it eliminates the download cost of clean, literate self-documentation.

Minify JS Online

JS Minifier

minify

jsmin-PHP

Packer The most efficient way to serve compressed JavaScript is to first run your code through a JavaScript compressor that shrinks variable and argument names, and then serve the resulting code using gzip compression. If you can’t use gzip compression for some reason, then Packer with base62 encoding turned on, is the next best thing. Scripts compressed with Packer are unpacked using one pass of a RegExp on most platforms. The strictness of Packer trips some people up, especially function declarations requiring a terminating semi-colon. This is not a habit for many JavaScript programmers. In this case I recommend using Julien Lecomte’s compressor first and then running the code through Packer for base62 compression. Remember that base62 compression is only necessary if you can’t use gzip. packer php packer
YUI Compressor Designed to be 100% safe and yield a higher compression ratio than most other tools. Tests on the YUI Library have shown savings of over 20% compared to JSMin (becoming 10% after HTTP compression). Starting with version 2.0, the YUI Compressor is also able to compress CSS files by using a port of Isaac Schlueter's regular-expression-based CSS minifier.

YUI Compressor Online

Online YUI Compressor

n/a

The JS CompressorRater uses all of these methods for easy comparison!  But don't assume the smallest file means the fastest load time.

Note Dean Edwards' recommendation to use Julien Lecomte's YUI Compressor first if the author of the JS doesn't use the required semi-colon (the popular prototype library could not be compressed with packer for this reason).  Also note that some minifier's can shrink variable and argument names, which can negatively impact some scripts that use public variables, including packer, ShrinkSafe and YUI compressor.

The benefit of having a PHP-based tool is that it allows dynamic compression and consolidation of JS and / or CSS files.  This could be useful if some files are necessary on all pages.

An important, related tool:

JSlint - the JS verfifier - might clean up bad JS, recommended before using any minifier, but especially JSMin and packer.

 



 
.
. Posted on Sunday, February 22, 2009 @ 16:42:11 CST by kguske   .
.
 
click Related        click Rate This        click Share

Speed up your site by optimizing your external JS and CSS | Login/Create an Account | 0 comments
The comments are owned by the poster. We aren't responsible for their content.

No Comments Allowed for Anonymous, please register



Page Generation: 0.04 Seconds