I just installed WP 3.1 Beta 2 on my test server. I noticed that it ships with a new l10n.js
file that gets automatically inserted into the header.
I did a bit of digging and it has something to do with localization. I’m guessing that many people don’t use this, so I’m wondering how I could remove it?
If it’s important not to remove it, please let me know as well.
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 usingwp_localize_script()
. Just search forl10n_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 nowconvertEntities()
is not defined when we need it. For this reason this function is split off the generalutils.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.
use the code above to deregister l10n.js in function.php
Looks like it is included when you enqueue the ‘comment-reply’ scrip. Note that you probably want to make sure ‘comment-reply’ is loaded only on pages could have comments enabled (e.g. check
is_singular()
before enqueueing the script).I found on my installation that this script was loaded alongside the new admin bar, getting rid of the admin bar got rid of the l10n.js for me(but i think Jan’s answer is more inline with answering the “why”).
Removing the bar was easy..
This doesn’t actually address the question(as evidenced by the other answers), but incase anyone wants to remove that awful bar, the above is how you do it..
How to remove it:
Drop in functions.php or whatever (plugin, etc.)
Works for me.
To remove it add the following to your theme’s functions.php file.
wp_deregister_script(‘l10n’);
Developers source for the file has following description:
and commit note says:
I hadn’t played with 3.1 yet so not sure what can make it load in every page.
Yep it’s thrown inside the theme by wp_head automatically…
I remove it by placing the code below in the theme’s functions.php
remove_action( 'wp_head', 'l10n' );