Thursday, February 9, 2012

Google Chrome slow? Disable extensions and get the real speed

I'm a Google Chrome fan since early versions. With every new version it consumed more memory. Today, after upgrading it to v. 17 I have decided to try Firefox v.10 What I saw was faster site rendering! Though FF seems to be less responsive (especially when switching tabs) sites were loading faster. It also  consumed less memory.

Finaly, I have disabled all chrome extensions with --disable-extensions switch. Viva Chrome! It's fast again!

If your chrome gets slower, disable extensions. You won't get fast page loads with extensions enabled.

Here's the extension list I was using:

  • Last Pass, 
  • Page Rank, 
  • Gmail Checker+, 
  • Firebug Lite, 
  • Smooth Gestures, 
  • RSS Finder, 
  • FlashBlock (that's the most suspicious one regarding the page load imho).
Question is "Is Google Chrome worth using without some of these extensions?" ...

Edit: You can also speed up Chrome with RAMDisk .
In my Chrome shortcut I added flags as follows:

--disk-cache-size=26214400  --media-cache-size=26214400 --disk-cache-dir=g:/ --purge-memory-button

This limits cache size to ~26 Megabytes.





Wednesday, February 1, 2012

Django language set in the database field applied on login

In one of my Django projects available only for logged in users I needed to set language setting in the database, so user can change the language setting in his profile.

Here comes a handy "user_logged_in" (Django >= 1.3) signal which lets us do things after user is logged in. In our case, we modify session and change the language.

My user_details.models.py:
from django.dispatch import receiver
from django.contrib.auth.signals import user_logged_in
from django.utils.translation import ugettext_lazy as _
from django.db import models
from django.conf import settings

class UserProfile(models.Model):
    user = models.OneToOneField(User, blank=Flse)
    language = models.CharField(verbose_name=_(u"Interface Language"), 
                   max_length=4, choices=settings.LANGUAGES)

@receiver(user_logged_in)
def lang(sender, **kwargs):
    lang_code = kwargs['user'].userprofile.language
    kwargs['request'].session['django_language'] = lang_code


settings.py

gettext = lambda s: s

LANGUAGES = (
    ('pl',gettext('Polski')),
    ('en',gettext('English')),
    ('de',gettext('Deutsch')),
)