node package manager

Introducing npm Enterprise add-ons. Integrate third-party dev tools into npm…

textwidth

Get some text's offsetWidth without rendering it in the DOM

textwidth

Get some text's offsetWidth without rendering it in the DOM

Define a style you want to compute:

var element = document.getElementById('foo');
 
textwidth.define('styleName', element);

Then, once defined, compute a string's width in that style like so:

textwidth.get('styleName', 'string whose width to compute');

All browsers IE5 and up (in theory - untested in not-Webkit!)

Yes.