News for hackers. Stuff that matters.
Re:Google Speed Tips Get Picked Apart by chaosmachine on Thursday June 25, 2009 @04:53PM (#674361)
Glad to see I'm not the only one who thought those PHP tips were more than a little suspect...

  GOOD: echo $_POST['description'];
That really should not have made it past their editorial process.
Re:Google Speed Tips Get Picked Apart by smokinn on Thursday June 25, 2009 @08:47PM (#674720)
That example was particularly egregious. PHP uses copy-on-write so the temp variable held a pointer to the 500k of data they mentioned, not a copy.

Had they concatenated a small string to the end then PHP wouldn't copied the data and used the MB of memory they alluded to.

That whole document was half baked at best.

EDIT: I went to look at the document to reference the example and noticed that they changed their example. It used to be:

$description = $_POST['description'];

echo $description;

And now it's:

In the following example, imagine if a malicious user had inserted 512KB worth of characters into a textarea field. This would result in 1MB of memory being used!

$description = strip_tags($_POST['description']);

echo $description;

There's no reason to copy the variable above, you can simply do this operation inline and avoid the extra memory consumption:

echo strip_tags($_POST['description']);

So someone is definitely working on making the examples at least match the description.

Re:Google Speed Tips Get Picked Apart by grandalf on Thursday June 25, 2009 @11:32PM (#674897)
I like the feature of assessing slow CSS. I'd never realized that constructs like the following would be "very inefficient":

  #foo p span{
    color: #fff;
  }
Re:Google Speed Tips Get Picked Apart by apsurd on Thursday June 25, 2009 @11:51PM (#674918)
i read it, but still have to ask why ?
Re:Google Speed Tips Get Picked Apart by dezwald on Friday June 26, 2009 @01:40AM (#675000)
it's inefficient because the browser has to search/loop through the DOM looking for the exact pattern of the corresponding css rules, instead of a direct pointer like:

#my_foo_span{ color:#fff }.

Re:Google Speed Tips Get Picked Apart by jonhohle on Friday June 26, 2009 @02:20AM (#675024)
but they mean different things. one says, all spans which are descendants of divs which are descendants of some elements with id=foo. the other says one element with id=my_foo_span. duplicating rules in CSS to match overly specific IDs defeats one of its major advantages.
Re:Google Speed Tips Get Picked Apart by grandalf on Friday June 26, 2009 @07:08PM (#676314)
one thing I don't understand is, does that mean it's bad CSS style? Is doing the suggested optimization equivalent to writing really huge functions in c before compilers could inline?
Re:Google Speed Tips Get Picked Apart by grandalf on Friday June 26, 2009 @12:50AM (#674966)
why they're inefficient?