View Full Version : Loading scripts in header question
11-07-2007, 02:05 AM
Hi I have a website that loads certain scripts depending on what is being page is being viewed. For example instead of having one main style.css I have a login.css account.css etc so that I only include the css files in the header that are relevant to the content on the page.
My question is is it faster to do it this way and load different scripts depending on what content is being viewed or is it faster to have just one script and load it. Is a script loaded every time a user goes to a new page on the website or is it cached? If it is cached when is this cache destroyed?
11-07-2007, 04:03 AM
I believe the script will be cached and will be cleared when the user specifies to clear it. Personally I would include them on all pages just in case. And if they're not used, no big deal.
heh, your at the same stage as I am and answering your question has helped me work out my thing. :thumbsup:
I have a website and a content management system, both of which use the same header appearance - ie my logo and stuff at the top. However, they use different styles and I want only those stylesheets, which are relevant, to show up in the appropriate page. This makes it easier too, for my brain to cope with updates to each site, without the fear of messing the other site layout.
So, to answer your question, my opinion is this:
to load any script, a 'function' is performed - the server has to do something. The instruction to load a content-specific stylesheet requires no more effort on the part of the server than the loading of a full stylesheet. However, the size of the stylesheet can make a difference, not least in terms of data transfer. So I am of the opinion that content-specific stylsheets are a better way to go because they can use less bandwith.
As for caching; stylsheets are cached and remain in your browser either until you delete it or if you have set it to clear the cache each time the browser is closed.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.