I use CodeIgniter and i love it, but i don’t know whether it’s really worth it to do like this:
<link rel="stylesheet" href="<?php echo base_url(); ?>css/main.css" />
<script src="<?php echo base_url(); ?>js/jquery.js"></script>
<script src="<?php echo base_url(); ?>js/functions.js"></script>
...
<img src="<?php echo base_url(); ?>images/dolphin.png" />
Rather than just:
<link rel="stylesheet" href="/css/main.css" />
<script src="/js/jquery.js"></script>
<script src="/js/functions.js"></script>
...
<img src="/images/dolphin.png" />
The first method adds a lot of weight to the page but it’s reliable when you decide to use the same app in a subfolder and such.
Which one should i go with?
If you think you might need to move the app to other subfolders (and not other sub domains), it probably is worth using
<?php echo base_url(); ?>, however if you can assume that the app will always be installed on it’s own domain or sub domain definitely do away with the function call, it adds unnecessary clutter and sends more to the users browser.It’s down to what you think your application will need to do.