Refactory the javascript code of loading contents on home page and
personal page