[theme-reviewers] Why themes should not use fopen?

Chip Bennett chip at chipbennett.net
Wed May 18 15:56:49 UTC 2011


If a user is defining 30kb of custom CSS, then it's probably time to
investigate use of a caching Plugin (most of which now also perform
minification).

In the end, whatever marginal gains one might observe by writing to a file
(and I tend to agree with Otto's statements below, that Method 1 is the most
efficient), those marginal gains do not outweigh the other considerations
regarding use of functions such as fopen().

Chip

On Wed, May 18, 2011 at 10:44 AM, Satish Gandham <satish.iitg at gmail.com>wrote:

> I followed the discussion on use of open that happened before,and read this
> several times,
>
>
> http://lists.wordpress.org/pipermail/theme-reviewers/2010-December/003192.html
>
> I'm not convinced whats suggested there as the best way is the best way.
>
> -----
> *
> *
>
> *Method 1: Insert the dynamic CSS directly into the HTML using the wp_head
> call.*
>
> *Method 1 has the lowest server impact. When you make the call to get*
> *the page, it creates the page and outputs all the dynamic stuff in one*
> *shot. Some people find the CSS in the html to be aesthetically*
> *displeasing, but the fact of the matter is that this is the fastest,*
> *simplest, and best way to do it.*
>
>
> How the server impact is the lowest? CSS has to be generated dynamically
> every time the page is loaded. Bandwidth is wasted as the CSS cannot be
> cached.
>
> If we go by method two described below, CSS is generated only when the
> theme options are changed and then its just loading the static file, that
> can be cached by the browser.
>
> My theme allows user to customize every element of the site and some styles
> are loaded only when the user enables a particular option.
>
> So, my dynamic CSS is around 30kb on average.
>
> In what way the above method is the BEST?
>
> When thousands are users are going to use my theme, I'm willing to spend
> extra time to offer the best solution rather than some simple and quick
> solution.
> *
> *
>
> *Method 2: Write dynamic CSS to a file, link to the file in the head.*
> *Method 2 has a problem in that you're doing file writing from the*
> *theme. This is bad because you cannot guarantee that you have*
> *permissions to even write files. Assuming you try to write them to the*
> *uploads folder, then part of your theme is now outside the theme*
> *directory, which is confusing. Also, by including the CSS as a*
> *separate file, you're creating another call to the server, which even*
> *Google Webmaster Tools will tell you is a thing to avoid.*
>
>
> Whats wrong with having a theme file outside the theme folder?
> What is confusing and Confusing to whom?
>
> An extra http request if far better than adding 30kb of weight to every
> page. Also considering the number of images loaded by theme and the number
> of stylesheets loaded the by plugins, the ONE additional http request is
> insignificant.
>
> Who told you they are confused?
>
> There are 2500+ users on my theme support forum, and none of them ever had
> problems with the stylesheet located in uploads folder.
>
> PS: I'm pretty sure that I wont win this like all arguments, but I couldn't
> just put 100kb of CSS and javaScript on every page and waste the bandwidth
> of the blog owner and the reader.
>
>
> Kind Regards
> Satish Gandham
>
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20110518/46cbaa9b/attachment.htm>


More information about the theme-reviewers mailing list