jQuery HTML Factory Extension


jQuery.html is an object which contains factory functions for creating new HTML/DOM elements. It is intended to replace inlined HTML code in script code. e.g.:

Old:
var x = jQuery("<div></div>");
becomes:
var x = jQuery.html.div();
It also provides a number of small conveniences, like simplified generation of tables:
var t = jQuery.html.table();
var tr = t.tr();
tr.td().append("Cell 1");
tr.td().append("Cell 2");
That will create a table with one row and two cells.

If you would like to see a standalone demo, click here.

Filename Size (bytes)
jquery.html.yuimin.js 2442
jquery.html.pack.js 2137
jquery.html.min.js 3103
jquery.html.js 6967

What the various *.js files are:
  • *.jquery.js or jquery.PLUGIN_NAME.js = the full-fledged, human-readable/editable source code files, including documentation for using the code.
  • *.pack.js = "packed" source code files, meaning they are optimized for maximum space savings (which also means obfuscated). They are created using one of the packers derived from http://dean.edwards.name/packer/.
  • *.min.js = source code files "minimized" for space savings using jsmin. They are not obfuscated, but are nonetheless not intended for human consumption.
  • *.yuimin.js = similar to the .min.js files, but these are compressed using the YUI minifier, which claims to be less error-prone than the conventional PACK method and smaller than normal MINinification. They are obfuscated, not intended for human consumption.
When deploying applications which use this code, the compressed versions are recommended, as they help reduce the download time of the application. Also, combining multiple scripts into a single file can notably reduce the download overhead.