slugify icon indicating copy to clipboard operation
slugify copied to clipboard

Option disabling `transliterate`

Open tunnckoCore opened this issue 3 years ago • 2 comments

Heya, great one.

Can we add options.transliterate so we can disable transliteration? Defaulting to true if you will so.

https://github.com/sindresorhus/slugify/blob/b841d04d92533469714e586435ed4c1b3b451d8c/index.js#L46

to

string = options.transliterate ? transliterate(string, {customReplacements}) : string;

tunnckoCore avatar Jun 08 '22 17:06 tunnckoCore

This would be great, we've seen transliteration add up to 250ms of processing time when we slugify a string, and as our website only operates in English it's generally not something we ever need.

philwolstenholme avatar Nov 20 '24 11:11 philwolstenholme

Library seems unmaintained so in-sourcing the code into one's own project seems the way to go. So if you're insourcing, some tips that may help

  • Commenting out transliterate is trivial. Even adding the option to true/false it is simple (an AI code editor could do it)
  • Transliterate is slow mainly because of all the Regex object creation. Simplest fix is to change it to a string.replaceAll (as the code comment suggests anyway). All modern browsers support this

glorat avatar May 29 '25 00:05 glorat