Hacker News new | ask | show | jobs
by colloqu 3975 days ago
This one is crazy. How are they so fast?
1 comments

No, forum.dlang.org is not crazy-fast. Other sites are crazy-slow.

Write compact and easy-to-render HTML, it's no rocket science. Write some trivial CSS, you don't need Bootstrap. Make something dead-simple and call it flat design. If you have more than one stylesheet, concatenate them into one. Consider minifying. You don't need a 200 kB JS framework in order to fade in some hover menu. If you do need more than one JS file, concatenate them into one. Minify/uglify and move the <script> tag to the bottom of your HTML.

You don't need 2 MB worth of stock photos. Recently, there was a page on HN with an uncompressed 12 MB banner photo. That is insane.

You don't need those heavyweight social plugins, they ruin your day (performance-wise). If your content is great, people will find a way to share. If your boss specifically asks for Facebook and Twitter buttons, just link to https://www.facebook.com/sharer/sharer.php?u=http://www.exam... and https://twitter.com/home?status=This%20is%20great:%20http://.... [1]

Don't just embed YouTube iframes, they are even worse. Use yt-embed.js [2].

Is a web font really necessary? If it is, do you really need Bold Italic? Sure as hell you don't need Ultralight+Light+Semilight+Regular+Bold, just because there is one ubercool Ultralight tagline in the footer.

Make sure Nginx or Apache gzip HTML, CSS and JS and send far-future Expires headers for all your static assets. Make sure that there are no redirects, they add latency.

If you follow these simple rules, your page weighs under 50 kB and needs no more than 10 HTTP requests. You don't even need complicated CMS caching and CloudFlare. But hey, there are some 10,000 cache plugins for WordPress, just install one.

[1] http://www.sharelinkgenerator.com/

[2] https://gist.github.com/do18/09761dfabf60689b2cd8

>No, forum.dlang.org is not crazy-fast. Other sites are crazy-slow.

You're ignoring that this site does use jQuery and webfonts and loads all of those pretty avatars separately. 22 requests, at my count.

For the reasons you list - i.e. words to the effect of "don't use all of this stuff" - I think that it is impressively fast, and their achievement shouldn't be hand-waved away quite so readily.

I'm not ignoring anything, I'm describing the philosophy behind sites like these: It seems that perfection is attained not when there is nothing more to add, but when there is nothing more to remove. [1]

Many seem to believe that there is some secret sauce involved in making web pages load fast. There isn't. Server-side caching is no rocket science. The key is to keep everything so simple that you have the overview over every delivered byte at all times.

Take a look at the HTML of forum.dlang.org. It's so simple, if it wasn't minified, I could immediately start working on this site. When someone asks me to work on some existing wiki or blog template, I usually spend an hour removing unused code first and I still struggle to find my way around the codebase. At that point, maintaining efficiency becomes impossible.

When you have a simple codebase, you may add a font, avatars, and jQuery. The trick is to think about whether you need it, not throw it in "just in case." Specifically, some tiny avatars won't hurt overall performance as long as the page doesn't need to be redrawn. Therefore, always specify width and height attributes for your img elements in HTML or CSS.

[1] https://en.wikiquote.org/wiki/Antoine_de_Saint_Exup%C3%A9ry#...

Lot of good points, thanks.

>You don't need 2 MB worth of stock photos. Recently, there was a page on HN with an uncompressed 12 MB banner photo. That is insane.

That seems to be a big trend nowadays and a huge pain.

What you're determining to be "needed" wrt design is very draconian and anti-progress. The web was ugly in 95 and appealed to few... progress in all areas -- especially design -- has made it what it is today.
I find that the prevalent user-friendly, minimalist design philosophy is very much compatible with performance principles like those that I have outlined.

Performance is not the opposite of UX, it is an important part of it.

What it is today, designwise, is awful, with screens littered with irrelevant content and extremely aggressive ads that are like xroach on steroids.