Asset Management in CodeIgntier

This is a quick tip, I wanna share with you all.

many of you must be using CodeIgniter for development of web apps. And I know everyone of you must have faced the problem of asset management (css, JS, images) in Codeigntier. Well here’s a quick tip for it and making it hassle free.

use of base tag in head section

First of all place all your files in some folder, this is how I use it. I always create three folders viz. css, images and js in root folder of codeigniter app. Then add following in head section

<base href=”<?php echo base_url(); ?>” />

After this, u can use only partial links in all you linking relative to you base href’s property!

For eg.

<script src=”js/jquery.min.js”></script>

and thats all, You won’t have to include base_url all the time in your codes for linking. It can be used for everything like images, scripts, css files etc.

Hope you find it useful!

Published by

Neeraj Kumar

#technologist #musician #traveller

  • http://www.neerajkumar.name/ Neeraj Kumar

    I received a tweet from a fellow friend @philsturgeo, he has also stated the same solution to this problem.

    Check his blog post at: http://bit.ly/ifEiD.

  • http://www.neerajkumar.name/ Snake

    I received a tweet from a fellow friend @philsturgeo, he has also stated the same solution to this problem.

    Check his blog post at: http://bit.ly/ifEiD.

  • http://etradewire.org/10495161/robert-shumake-rescues-detroit-pension-avoiding-costly-suits-and-losses.html Robert Shumake

    Your blog is so informative … ..I just bookmarked you….keep up the good work!!!!

    Hey, I found your blog in a new directory of blogs. I dont know how your blog came up, must have been a typo, anyway cool blog, I bookmarked you. :)

    Robert Shumake

    • http://www.neerajkumar.name/ Neeraj Kumar

      Thanks Robert. I really appreciate it!

  • http://etradewire.org/10495161/robert-shumake-rescues-detroit-pension-avoiding-costly-suits-and-losses.html Robert Shumake

    Your blog is so informative … ..I just bookmarked you….keep up the good work!!!!

    Hey, I found your blog in a new directory of blogs. I dont know how your blog came up, must have been a typo, anyway cool blog, I bookmarked you. :)

    Robert Shumake

    • http://www.neerajkumar.name/ Snake

      Thanks Robert. I really appreciate it!