Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
11-07-2007, 01:05 AM #1
- Join Date
- Oct 2007
- Thanked 0 Times in 0 Posts
Loading scripts in header question
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, 03:03 AM #2
- Join Date
- Mar 2007
- Thanked 7 Times in 7 Posts
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.
11-08-2007, 10:07 PM #3
- Join Date
- Apr 2003
- in my house
- Thanked 201 Times in 197 Posts
heh, your at the same stage as I am and answering your question has helped me work out my thing.
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.