Softpedia
 

NEWS CATEGORIES:



NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
Home > News > Webmaster > Tips and Tricks

April 9th, 2008, 15:46 GMT · By Catalin Bocanu

The Free Super Mario Game: Only 14kB

SHARE:

Adjust text size:


Super Mario Javascript
Enlarge picture
Every Internet user likes fast loading online games, web pages or other applications. The secret of web pages and application optimization resides greatly in code structure.

JavaScript, as a client-side programming language, is widely used
for addition of various features and functionalities to websites. There are many aspects that influence the final script size. The aim of code optimization is to reduce the file size of the script in order to decrease the page loading time and bandwidth consumption.

The compression tools available as desktop applications, standalone scripts and free online services, will optimize the entire structure of the JavaScript code. As a consequence, the code optimization utility will remove white spaces, comments, obfuscate local variables with shorter variables names and more.

Usually, compression of Javascript code will allow you to obtain a reduction of final file size with up to 50 percent as compared to the original version. Of course, the initial selection of coding algorithm and variables name will also influence the compression effect.

For example, Super Mario Game is a single Javascript file that in uncompressed form has 35 kb. The game does not use external image files (the entire game is rendered with the help of JavaScript) and the music is included as encoded data. All aspects related to the code structure were optimized from the beginning, like game sprites reprezented in encoded strings determining their size of only 60 bytes for a single sprite. After the code compression with YUI compressor, the JavaScript file size was 14 kb.

In conclusion, the optimization of Javascript code through specific compression methods will show the best results (as the decreasing of initial file size with 50%) if the initial code has a certain optimization degree from the project design phase. The Javascript as well as HTML and CSS code could also support compression on the server side, but not all browsers have the capability of decompressing the files on the client side.

TELL US WHAT YOU THINK:

11,752 hits · Link to this article · Print article · Send to friend · Subscribe to news

MUST-READ RELATED ARTICLES:


Free Download Jabber Clients Made With Javascript

How To Add Google Gadgets in Joomla!

Automatic Text Translation with Javascript

Get A Free Flash Image Gallery

An Unwanted Trip To A Porn Website ?

READER COMMENTS:



No user comments yet.
Be the first to express your opinion!
Copyright © 2001-2012 Softpedia. Contact/Tip us at

WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM