javascriptcsscodeigniter

how to avoid from loading unnecessary javascript and css in page on codeigniter to improve the load time


Generally all the css and javascript is loaded in the top and bottom respectively. But on some pages there is no need of load all the javascript and css files. So, how do i prevent to load the unnecessary files from the selected page.


Solution

  • You have two thing to do.

    1. Divide the header CSS and JS to separate files.
    2. Ignore it.

    Method 01

    If your home page load slider and all. So create header only for home with header_home.php. and other pages just use CSS and JS. so remove slider JS and CSS and create another one with header_inner.php

    Method 02

    Just leave it as it is, because it will not affect to your site performance. It works once is called out only.