trimMiddle()

CSS can truncate text on a single line or on multiple lines, but it always does so from the end of the text. I’ve seen a (bad) trick reversing the text direction to trim text from the front instead, but never from the middle.

Christian Heilmann wrote a package to help with this. I agree it’s a better solution particularly for file names/paths as both the beginning and ending hold more important information than the middle.

It's time to take your JavaScript to the next level

Leave a Reply

Your email address will not be published. Required fields are marked *

Did you know?

Frontend Masters Donates to open source projects. $363,806 contributed to date.