Google To Promote Web Speed On New Dev Site
CWmike writes "Google has created a Web site for developers that is focused exclusively on making Web applications, sites and browsers faster. The site will allow developers to submit ideas, suggestions and questions via a discussion forum and by using Google's Moderator tool. Google hopes developers will join it in improving core online technologies such as HTML and TCP/IP. For Google, a prime example of how Web performance can be enhanced is the development of HTML 5, which provides a major improvement in how Web applications process Javascript, Google believes. 'We're hoping the community will spend some time on the basic protocols of the Internet,' Google product manager Richard Rabbat said. 'There's quite a bit of optimization that can be done [in that area].'"
HTML - as opposed to XHTML, even when delivered with the MIME type text/html - allows authors to omit certain tags. According to the HTML 4 DTD, you can omit the following tags (tags of so-called "void" - empty - elements are marked as strikethrough):
For example, if you have a list of items marked up as <li>List item</li>, you could instead just write <li>List item. Or instead of a paragraph that you'd usually close with via </p>, you could just use <p>My paragraph. This even works with html, head, and body, which are not required in HTML. (Make sure you feel comfortable with this before making it your standard coding practice.)
Omitting optional tags keeps your HTML formally valid, while decreasing your file size. In a typical document, this can mean 5-20 % savings.
Now, my first reaction was simply "that cannot be valid!" But, of course, it is. What I found interesting is that when I looked at the source for that tutorial they themselves are using </li> and </p>. Interesting, huh? You would hope that Google would follow the very advice they are trying to give you.
Some of these suggestions may come at the cost of readability and maintainability. There's something about web pages being nice tidy properly formatted XML documents with proper closing tags that I like.
My work here is dung.
Comment removed based on user account deletion
We've got to slashdot their site for ultimate irony! :)
The skinnier ones compress much easier.
I have this great and innovative idea. Take your browser-based e-mail client and word processor, rewrite them in native machine code and run them alongside the browser, as a separate app, instead of inside it. For even more speedup, the data could be stored on the hard drive instead of downloaded from a remote web-site. Never seen before!
My first program:
Hell Segmentation fault
I remember the golden days, when I had limited online time allowed because AOL was metering my parents dial-up connection; webpages actually loaded on dial up. Yes, you heard me, dial up could load any web page on the Internet. After broad-band came up, certain web pages started slowly taking longer and longer to load; today, dial up just doesn't cut it. I suppose we have the same problem with processing resources.
"Sorrow is better than laughter, for by sadness of face the heart is made glad." [Ecclesiastes 7:3]
While the ideas are good, I'd be more impressed if they fixed their own timewasters.
For example, the search function for google groups (That's the history of the internet, since 1983, from long before the WWW). It's been broken for almost 2 years.
making Web applications, sites and browsers faster.
Anybody up for sending the Slashdot developers there?
Why oh why was this in video format?
As any open source developer knows, what's needed is more ideas, suggestions, and questions. Later, once the discussion group has come to consensus, we'll write some code.
Gah!
Say it with me: "Use prepared SQL queries not concatenation!"
Their video is dynamically building the SQL statement, which is full of injection possibilities.
You mean like Progress? Since OE10 Webspeed errors have dropped off considerably... http://web.progress.com/openedge/webspeed-worshop.html
I judt got a nre Kinesis keybiartf so please excusr ant egregiou typos.
The echo case is when you're doing something like
Do
instead, using ' instead of " to reduce the processing needed to parse the strings and , to echo out all of the pieces without actually doing the extra processing of concatenating them into a single string object that you don't want anyway.
HTML/HTTP were never designed as a method for running remote applications and shouldn't be used as such. We spent all these years upgrading to the latest Core 2 Trio so we could make the internet connection the new bottleneck.
Yes I realise that for n00bs its all about the convenience of web apps but client-side apps need not be inconvenient. Look at the iPhone app store, n00bs love it and its full of client-server applications. If there was something like it for Windows and OS X we'd never need to work with a horrible "web application" ever again. Linux doesn't need any, package managers could do with a bit more eye-candy and buttons with round edges for n00bs but for the rest its fine.
I'm all for optimising web pages but one should focus on minimalism, only use AJAX in cases where it actually saves bandwidth rather than using it for useless playthings. Use a CSS compressor, gzip compression, strip out useless eye-candy and effects, use as little javascript as you can get away with.
Modern web design thrives on feature-creep and making one's own site look better (and more bloated) than the competitor's. The web devs have a skewed perception of how long it takes to load because most of them are using decent machines and accessing the server through 192.168.1.x
Comment removed based on user account deletion
There was an article here on /. some time ago that affirmed that google ads/analysis was slowing down the web. In my personal experience, this has normally been true, most of the time when a major webpage is taking time to load up, I see 'Waiting for [insert something google]...'.
An ideal solution would be some way to store the prepared version of a query on the server.
Like Google Analytics, or Google Ads. When Google went pear-shaped some time back it made a significant portion of the Web unusable. If your own server is down, no big deal. If other sites depend on your server, then it's a problem.
While I'm slagging off Google, why don't they stop Doing Cool New Stuff and improve their fucking search engine instead?
Potato chips are a by-yourself food.
Yahoo! has a handy page (http://developer.yahoo.com/performance/) with lots of good info. It includes YSlow (a Firefox add-on), a set of "Best Practices," and some good research. Also references a couple of O'Reilly books (which, to be fair, I haven't read).
More specifically, CSS sprites (see http://www.alistapart.com/articles/sprites/) and consolidating Javascript may be back (reducing HTTP requests), and a few other things that may surprise or inform.
I don't know about MySQL, but prepared statements in most major RDBMs will allow the database to cache the query plan as well as being more easily optimized. So they actually are much -faster- if you need to execute the query over and over (especially if you can reuse the same query object). Many database APIs will also let you use statement objects that have the same capabilities as prepared statements in term of query plan caching and safety, but do not do the first roundtrip to optimize the query on the server, so if you are just going to execue the query once, you can still use a parameterized query without the double roundtrip.
ORM (Object relational mappers) will use these methods internally and are fairly pervasive in high performance application.
And its not wasteful even if you control the sql, again, because of the query plan caching abilities that it provides.
The number one slowdown I see on pages is linking to all kinds of external resources: images, flash movies, iframes, CSS, bits of javascript. Each of these requires at least another DNS lookup and a new HTTP connection, and often those external servers take a really long time to respond (because they're busy doing the same for all those other websites using them). Why is this going on in each users browser? It should all be done behind the scenes on the web server. Why would you put the basic user experience of your users or customers in the hands of random partners who are also doing the same for competing sites? It takes some load off your server, but I think the real reason that people just link in external resources as images, objects, etc is just that it's easier than implementing it in the back end. If you really want to offload work, then design a mechanism that addresses that need specifically.
We've ended up with a broken idea of what a web server is. Because it was the easiest way to get started, we now seem to be stuck with the basic idea that a web server is something that maps request URLs directly to files on the server's hard disk that are either returned as is or executed as scripts. This needs to change (and it is a little bit, as those "CGI scripts" have now evolved into scripts which are using real web app frameworks.)
Most web sites/apps are running the same queries many times over. And eliminating the need for the developer to pre-sanitize input both simplifies code and helps protect against bugs & missed cases.
Or you could go all the way and use stored procedures and/or views for your most common queries.
I was having a look over Opera Unite services when looking to write one of my own, and i noticed this handy little function.
It fetches all the external page objects after the initial page has loaded.
Sadly, the example (homepage) failed in the sense that the basic CSS was not always the first thing to be loaded, which resulted in buckled pages on tests for slow upload speeds. (and some things weren't obviously clickable objects before images were loaded in)
So, in this way, an initial page could be loaded that is, at a minimum, functional, then load in all the fancy-shmancy stuff if they have JavaScript enabled.
I would love to see more people take advantage of that since a good deal of the time, websites are sitting there loading loads of crap that end up going unnoticed anyway.
Always always always load the most important stuff first. But sadly, "most important" has gone from page content to stupid sponsor stuff, crappy flash ads, useless headers that take up an eighth of the screen, shiny flowing menus, etc. (some of these being the reason i want Flash to die a painful death since it is one of the major causes of slowdown, DEATH TO PLUGINS!)
off-topic
Also, i am loving the way Unite services are created so far.
JavaScript, HTML, CSS and XML, none of that PHP, or Python or anything else, just all native browser technology.
Comment removed based on user account deletion
That article says "It's better to use concatenation than double-quoted strings." Every legitimate benchmark I've seen has shown that the difference is zero to negligible. In tests that I've run myself, concatenation actually scales worse; a dozen concatenation operations are slower than one double-quoted string.
As for using commas with echo, why aren't you using a template engine?
More and more, sites are generating the message "A script on this page is running too slowly" from Firefox. Not because the site is hung; just because it's insanely slow. Slashdot is one of the worst offenders. The problem seems to be in ad code; Slashdot has some convoluted Javascript for loading Google text ads. Anyway, hitting "cancel" when Slashdot generates that message doesn't hurt anything that matters.
Facebook is even worse. Facebook's "send message" message composition box is so slow that CPU usage goes to 100% when typing in a message. Open a CPU monitor window and try it. I've been trying to figure out what's going on, but the Javascript loads more Javascript which loads more Javascript, and I don't want to spend the debugger time to figure it out.
From TFA:
Sometimes PHP novices attempt to make their code "cleaner" by copying predefined variables to variables with shorter names. What this actually results in is doubled memory consumption, and therefore, slow scripts.
It seems to me that this is a flaw in the PHP interpreter, not the PHP programmer. The way I see it, the interpreter should be lazily copying data in this case. In other words, the "copy" should be a pointer to the original variable until the script calls for the copy to be changed. At that point the variable should be copied and changed. I believe this is how Python handles assignments, and I'm surprised that PHP does not do it the same way.
We all know what to do, but we don't know how to get re-elected once we have done it
Comment removed based on user account deletion
...available to Google developers? Because some of the slowest applications on the planet are Google apps: The gmail and adwords applications come immediately to mind.
I think it's somewhat disingenuous to imply that slow web interfaces are someone else's problem when in fact Google is probably one of the worst perpetrators when it comes to slow interfaces.
I'm very wary of anything lossy, or compiled, or anything that "strips out useless parts" of the HTML. HTML, javascript, etc is great because it is open and largely human-readable, anyone who downloads it can also analyze the code. This makes it safer, more controllable, and more understandable, at least for the end user. If anything is to be done about the size of the download it should be some sort of lossless compression algorithm optimized for HTML/javascript/etc. If the process is not fully reversible on the user's end, I think it will ultimately be harmful to the internet.
Just think how hard it would be to block ads if each page was a compiled program instead of human-readable code.
If only it wasn't being blocked by so many people because of the abuse by other peolpe, who were really abusing the fact that most browsers that have JavaScript support were designed so terribly, the world wide web would have been so much better than the crap we see today.
But no, we have websites designed around spamming new windows and alert boxes on all of them.
THANKS WEB BROWSERS VENDORS, WE COULDN'T HAVE DONE IT WITHOUT YA'.
All of them are to blame, every damn one of them.
And i blame Mozilla more for the fact that THEY never done a damn thing to change the rules.
Fuck W3C, why the fuck does anyone even listen to them anymore? They ruined the web time and time again, and STILL ARE. They have shown many times that they are incapable of deciding what is good for the web.
Google, while they are doing things, are only doing it because they want browsers to catch up with things like the terribly optimized iGoogle and other services.
Seriously, fix the damn iGoogle page, it doesn't need to do half the shit it does. Start using the "dynamic" shit you are trying to push, would ya'? (also, the fact that someone above mentioned them going against their own guidelines with respect to certain elements.)
Just think, we could be compressing pages in JavaScript, delivering them, decompressing them and bham, saved a ton of bandwidth.
We could have had JavaScript written pages actually showing up in View Source pages, instead of the horribly coded examples we currently have that REfetch pages. (most cases)
Of course, the worst offender is always going to be Microsoft. They are the ones that led the others down the road of buckled support for years, eventually killing some of them off because losing control of the web could* have eaten away at the desktop market.
*It now is, and has been for a few years now with more and more software being sold online instead of shops, or being offered for free, or being entirely hosted through a webpage.
For those who are into web site performance, like me, the standard tool for everyone was Yslow, which is a Firefox extension that measured front end (browser) page loading speed, assigned a score to your site/page and then gave a set of recommendations on improving the user experience.
Now Google has the similar Page speed Firefox extension.
However, when I tried it, with 5+ windows and 100+ tabs open, Firefox kept eating away memory, and then the laptop swapped and swapped and I had to kill Firefox, and go in its configuration files by hand and disable Page Speed. I have Yslow on the same configuration with no ill effects.
2bits.com, Inc: Drupal, WordPress, and LAMP performance tuning.
Don't copy variables for no reason.
Sometimes PHP novices attempt to make their code "cleaner" by copying predefined variables to variables with shorter names. What this actually results in is doubled memory consumption, and therefore, slow scripts. 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!
BAD:
$description = $_POST['description'];
echo $description;
GOOD:
echo $_POST['description'];
Now I would never question the almighty Google, but the Rasmus Lerdorf taught me that PHP uses copy-on-write. Quoting from his O'Reilly Programming PHP book:
When you copy a value from one variable to another, PHP doesn't get more memory for a copy of the value. Instead, it updates the symbol table to say "both of these variables are names for the same chunk of memory."
So who's right? I tend to believe M. Lerdorf since he pretty much invented PHP but like I said before I'm not an expert and my book is pretty old so (PHP 4.1.0) so maybe that has changed since (although I doubt it)...
It does.
From Chapter 2.3.4. Garbage Collection in Orelly'S Programming PHP:
PHP uses reference counting and copy-on-write to manage memory. Copy-on-write ensures that memory isn't wasted when you copy values between variables, and reference counting ensures that memory is returned to the operating system when it is no longer needed.
To understand memory management in PHP, you must first understand the idea of a symbol table . There are two parts to a variable--its name (e.g., $name), and its value (e.g., "Fred"). A symbol table is an array that maps variable names to the positions of their values in memory.
When you copy a value from one variable to another, PHP doesn't get more memory for a copy of the value. Instead, it updates the symbol table to say "both of these variables are names for the same chunk of memory." So the following code doesn't actually create a new array:
$worker = array("Fred", 35, "Wilma"); // array isn't copied
$other = $worker;
[... snip ...]
http://docstore.mik.ua/orelly/webprog/php/ch02_03.htm
Hypercard used to have this handy feature - prior to making any big changes, you could call 'lock screen', then mess with the display to your heart's content, then 'unlock screen' (optionally with pretty transition effects). Maybe what we need is something similar - let's face it, most large web sites are fairly unusable when they're loading, as they get randomly reformatted as various resources get loaded and start messing with the page.
Simple double-buffering primitives would allow smooth loading, and probably speed things up a lot as the browser could suppress unnecessary redraws.
When you do a POST|GET you send the request as is uncompressed. The server normally replies with the data compressed. We should have a method to allow sending compressed headers. This alone would save tons of b/w. More so when dealing with AJAX sort of requests. Think about it, you do something tiny to change a flag or a few characters of text and massive headers are being sent. More often than not your up-stream b/w is going to be way lower than down. Also, when serving content it is best to have it on another domain name or virtual host of sorts. If you are serving all your data from the same server then you will be sending massive cookie headers even when fetching images for the page.
Whatever happened to JPEG2000? (Patent problems?)
SVG should've been here long ago. IE will continue to slow SVG adoption in the real world.
If we could get JPEG2000 (or something like it) and SVG in 95+% of browsers, I think we'd be golden. That and getting rid of IE6 with its broken box model (among many other problems), would go a long way towards modernizing the Web. Take HTML5 and add the top 10 features or so of CSS3, and it's party-time for web devs once again. MS needs to shit or get off the pot with IE.
Im excited about this, been working on a site Impostor Magazine and been using flex and different tools... nice to have a place to play and test.
One thing I've never really understood is why closing tags in XML have the tag name? Surely the angle brackets with slash inside would be enough since (assuming the markup is valid) it is obvious to the parser which tag is being closed: e.g. (I've used underscores to indent... I can't make the slash-code use spaces!!)
:D
<html>
__<head>
____<title>Example</>
__</>
__<body>
____<h1>Example</>
____<p><em>This <strong>is</> an</> example.</>
__</>
</>
I know this makes it hard for a human to see opening/closing tags, but if XML parsers (including those in browsers) were able to accept markup with short close tags or the normal named close tags, then we could: 1. benefit where the markup is machine generated and, 2. easily pre-process manually created markup.... it's easy enough to convert back and forth.
But maybe there's a good reason for not doing this that I'm missing... but it's always bothered me!
I'm glad to see that at least web development is still concerned with optimization. The glut of RAM and processing speed has made desktop developers lazy and sloppy, and it has become the norm for software to be bloated and inefficient.
<sarcasm>Why bother finding a more efficient way to do [whatever] when you're talking microseconds at the user's end?</sarcasm>
I'm actually sort of surprised a glut of bandwidth and server power hasn't led to a similar "kitchen sink" approach to web technology.
Then again, I suppose it has. Just look at any given Web 2.0 Ajax monster...and on the web we're often talking WHOLE SECONDS lost to poor optimization and badly thought out apps.
Porquoi?
I myself waist the most time on the Internet with Spam. So lets fix the most annoying things first.
Start signing your e-mail so I can filter on a reliable source where it comes from and use the web of trust to indicate if I have any 'remote' trust relationship to the sender.
Busy helping non technical users of OpenOffice.org - http://plan-b-for-openoffice.org/
For the record, Google's very first claim (about copying variables doubling memory consumption) is dubious. Although the language itself passes most variable types by value, the PHP interpreter copies variables lazily using copy-on-write. So in general, "aliasing" variables for readability should be OK. However, I'm not sure whether the interpreter copies individual array elements lazily...