What does l10n.js do in WordPress 3.1? And how do I remove it?

It contains the convertEntities() function that (as the name says) converts HTML entities to their actual value. It is mostly used for scripts that send over localization data from PHP to the JS side using wp_localize_script(). Just search for l10n_print_after in the code base and you see it a lot.

The data you add in wp_localize_script() is added before the script it translates (it must be, because it is referenced there). However, if you use a script concatenator (so you only have one request that returns all used JS files), this one file would also be called after all localized data – but now convertEntities() is not defined when we need it. For this reason this function is split off the general utils.js file and added with a high priority at the top.

For this reason you should not remove it: all scripts that use translatable strings use it (even if they are still in English), and you might break places that still have entities.

Leave a Comment