Re: including CSS & JS on only pages that need that CSS & JS [message #175578 is a reply to message #175577] |
Mon, 10 October 2011 00:03 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 10/9/2011 7:54 PM, Jerry Stuckle wrote:
>
> None of which are a good idea. And so those who keep espousing these
> crappy solutions (which are off topic in this newsgroup but there are so
> many of them I will respond anyway):
>
> CSS files should be CSS files - and should not have a .php extension;
> there is almost never a need for any php code in a css file. The same
> with javascript and .js extensions.
>
> And files should be included using link tags, not directly included in
> the source file directly (unless they are specific to this page - in
> which case there is no need for conditional includes). That way file can
> be cached by the browser and/or routers between the web server and the
> client, decreasing both network traffic and server load.
>
> There are a lot of things "that work" but are not a good idea.
>
I should also add - unless the op has thousands of lines of javascript
or css unused on a page, these attempts will actually decrease
throughput. There is almost always more overhead in requesting another
file (css or javascript) than there is just getting the file once and
using it.
This whole question sounds like premature optimization - which is very bad.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|