Speed Up Wordpress Page Loading Times By Removing l10n.js - gHacks Tech News

Speed Up WordPress Page Loading Times By Removing l10n.js

I recently noticed that my WordPress blog's page loading times increased through the roofs which made me reevaluate everything that contributed to the loading times of the website. I implemented a few changes on the blog to improve page loading times. I first got rid of the three social networking buttons pointing to Google Plus, Facebook and Twitter, and replaced them with the Add This script instead. The benefit here was that it reduced the external JavaScript code that needed to be loaded for the functionality from three to one.

I also noticed that articles with hundreds of comments were loading significantly slower than pages with less comments. This made me reduce the number of comments per page to 50 root comments (plus their answers).

Today I noticed that WordPress added another JavaScript to every page. The script in wp-inlcudes/l10n.js that is related to the admin bar that the WordPress developers added to one of the recent versions of the blogging platform.

While it is a small file with a size of 233 bytes it is still a script that is loaded by anyone, not just the admin of the blog. This somehow does not make a lot of sense. The important thing here is that the blog needs to make the request to load the element, not the time it takes to load the 223 bytes.

WordPress administrators may want to remove the JavaScript element from being loaded by every blog visitor to speed up the blog's page loading times. The easiest way to remove the l10n.js from being loaded with WordPress is to unload it in the functions.php file in the WordPress theme folder.

All you need to do for that is to add the following line of code to the end of the functions.php file.

wp_deregister_script('l10n');

Please note that this may disable part of the admin bars toolbar functionality. Users over at Stack Exchange have found a way to keep the JavaScript loaded for administrators of the blog.

if ( !is_admin() ) {
function my_init_method() {
wp_deregister_script( 'l10n' );
}
add_action('init', 'my_init_method');
}

Just add this code instead to the functions.php file.

Summary
Speed Up WordPress Page Loading Times By Removing l10n.js
Article Name
Speed Up WordPress Page Loading Times By Removing l10n.js
Description
The guide explains how you can prevent the file l10n.js from being loaded when users connect to your WordPress powered website.
Author

We need your help

Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.

We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.

If you like our content, and would like to help, please consider making a contribution:

Comments

  1. Renji said on October 25, 2011 at 2:50 pm
    Reply

    Hi Martin, the AddThis script is returning error. I am seeing “t' src='http://static.fmpub.net/site/ghacks'>function initAddThis() { addthis.init() } // After the DOM has loaded... initAddThis();” at the end of all pages.

    1. Martin Brinkmann said on October 25, 2011 at 3:07 pm
      Reply

      Renji,

      thanks so much. Have repaired it.

  2. C.C. said on October 25, 2011 at 3:02 pm
    Reply

    Hey Martin, This is a great article. I have an idea/request for an article along a similar line (for the end user vs. the content provider).

    Gawker Media sites have horrific page loading/rendering times. I’m on Win 7, FF 7.0.1 w/ Adblock. Plus. The general consensus seems to be Adblock as the culprit to an already slow site design but no one seems to have a solution. Could you do an analysis/solution on what we could possibly filter in order to improve it?

    I realize it’s sort of seems like helping your competition but I think if you were able to figure this out, you’d get ALOT of thankful people coming to Ghacks. I also believe people read those other sites along with ghacks already so it’s not like you’d be losing anything – you’d only just be getting more readers.

    Just an idea. TIA if you can do it.

    1. Martin Brinkmann said on October 25, 2011 at 3:10 pm
      Reply

      I do not really used adblock or another adblocker. In theory, it should speed up the page loading times because it blocks some scripts from being loaded. Have you tried NoScript? It blocks all the scripts on Lifehacker (you need to enable one or two for the contents).

      1. C.C. said on October 25, 2011 at 5:47 pm
        Reply

        One would think that would be the case – and it is in general EXCEPT for Gawker sites it is the complete opposite which is one of the reasons why there was such a backlash when they revamped their site design to it’s current iteration. In a nutshell, the method they used to code it is supposedly ridiculously and unnecessarily complex.

        NoScript is too indiscriminate for my tastes. While it is very powerful, whitelisting every specific element for every new site i visit is WAY too tedious. Half the times, i didnt even know I was missing out on content because a script was stopped – constantly toggling NoScript to double check if i missed anything is too time consuming. NoScript is good if you only repeatedly visit the same sites over and over again, but it is too much hassle if you like to visit new sites as well.

        So does that mean you won’t look into it? AdBlock Plus is the #1 most popular extension used across all browsers. Gawker sites are the most trafficked blogs. This is a huge demographic you are missing out on.

      2. Guest said on October 26, 2011 at 3:50 pm
        Reply

        You wrote an article a few days ago disheartened by the fact that people don’t seem to comment on your posts. So i posted a comment.

        I was polite, offered an informative point of view, suggested material for you, and asked for help.

        Thanks for not responding to my simple question.

        I will go back to not commenting and just skimming your headlines. Don’t whine anymore when you don’t get comments.

      3. Martin Brinkmann said on October 26, 2011 at 4:26 pm
        Reply

        Which comment are you referring to?

      4. Martin Brinkmann said on October 26, 2011 at 4:39 pm
        Reply

        You are annoyed that I did not reply in less than 24 hours to your comment? Do not you think that is a bit harsh?

  3. Klemen said on October 25, 2011 at 3:48 pm
    Reply

    Adding this breaks my theme design and also causes some errors in the admin section.
    I’m using the “Statement” theme.

  4. Usman said on October 25, 2011 at 7:24 pm
    Reply

    For those who are using Thesis theme:

    //Remove the admin bar script for non admin users.
    function remove_adminbar () {
    if (!is_admin()) {
    function my_init_method() {
    wp_deregister_script( ‘l10n’ );
    }
    add_action(‘init’, ‘my_init_method’);
    }
    }
    add_action(‘thesis_hook_before_html’,’remove_adminbar’);

  5. Twolane said on October 26, 2011 at 3:19 pm
    Reply

    Sorry, but in Thesis this breaks some of my Thesis themes with a

    “Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE in /home/dupha/public_html/wp-content/themes/neoclassical_182/custom/custom_functions.php on line “

  6. Twolane said on October 26, 2011 at 4:35 pm
    Reply

    Sorry, but in Thesis this breaks some of my Thesis themes with a

    “Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE in /home/dupha/public_html/wp-content/themes/neoclassical_182/custom/custom_functions.php on line “

    For those who are using Thesis theme:

    //Remove the admin bar script for non admin users.
    function remove_adminbar () {
    if (!is_admin()) {
    function my_init_method() {
    wp_deregister_script( ‘l10n’ );
    }
    add_action(‘init’, ‘my_init_method’);
    }
    }
    add_action(‘thesis_hook_before_html’,’remove_adminbar’);

    1. Martin Brinkmann said on October 26, 2011 at 4:39 pm
      Reply

      Again thanks for posting.

  7. Sammy Zimmermanns said on October 27, 2011 at 11:46 am
    Reply

    Hey, Martin thanks for your post.

    Wie geht es Dir?

  8. Leo said on October 29, 2011 at 2:10 pm
    Reply

    If I remove it, will it break WordPress?

    1. Martin Brinkmann said on October 29, 2011 at 2:12 pm
      Reply

      no you won’t. But your theme may require different instructions to remove the file.

  9. Graha Nurdian said on January 22, 2012 at 8:22 pm
    Reply

    I found out this tricks reduce my page loading speed significantly. Thanks for sharing :D

  10. Ryan said on May 14, 2012 at 10:57 pm
    Reply

    I’ve used CloudFlare on my site to help speed it up, but couldn’t find a way to speed up the actual load time. Thanks to that script my site load time was cut in half. Thanks!

  11. shekar said on August 27, 2012 at 4:19 pm
    Reply

    thanks for measuring the site speed

  12. shekar said on August 27, 2012 at 4:23 pm
    Reply

    thanks for the news of site value checking .firstly i donot measure my site but for seeing your blog .I check my site value.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

Please note that your comment may not appear immediately after you post it.