CodeIgniter Forums
embedding stylesheet when you load multiple views - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: embedding stylesheet when you load multiple views (/showthread.php?tid=53274)



embedding stylesheet when you load multiple views - El Forum - 07-17-2012

[eluser]jtan[/eluser]
what's best practice for...

when you're going to load multiple views, like heading, main page, footer, do you have stylesheet for each view or load 1 view for stylesheet then load the other views (without stylesheet)?


embedding stylesheet when you load multiple views - El Forum - 07-17-2012

[eluser]kanjimaster[/eluser]
Stylesheets should be in the html header, so however many you have they shouldn't be being loaded with each view.

Whether you have one or many depends on the relative importance of maintainability and performance. Different stylesheets dealing with different parts of the site may be easier to maintain, but each requires an HTTP request from your visitors' browsers causing slightly slower page loading.

Personally I lean towards using LESS and then pre-processing, concatonating and minifying them into a single file to get the best of both worlds and there are several codeigniter sparks that can manage this for you.


embedding stylesheet when you load multiple views - El Forum - 07-17-2012

[eluser]jtan[/eluser]
Did I get you correctly that you're lean toward having 1 view that loads the stylesheet then succeeding views not loading any stylesheet?


embedding stylesheet when you load multiple views - El Forum - 07-17-2012

[eluser]kanjimaster[/eluser]
Sort of. If you have a view that loads the HTML head tag and other meta values, all your stylesheets should be loaded within that view.

Stylesheets loaded with your footer say, would be loading in a location that breaches web standards and would slow the loading of the footer as they'd require an extra HTTP request to be completed before the footer can be finished.