I have a jQuery plugin on GitHub: https://github.com/MartinF/jQuery.Autosize.Input
This is approximately 1.6 kb, reduced.
Here you can see a live example: http://jsfiddle.net/mJMpw/6/
Example:
<input type="text" value="" placeholder="Autosize" data-autosize-input='{ "space": 40 }' />
input[type="data-autosize-input"] {
width: 90px;
min-width: 90px;
max-width: 300px;
transition: width 0.25s;
}
css min/max-width , .
/ json -autosize-input .
, jQuery
$("selector").autosizeInput();