5 ms·
Speeding up this site by 50x (2014)
- theandrewbailey 4y agoThat's awesome! Yeah, you can definitely go overboard with webfonts. The 3 that my blog[0] uses are base64 URLs in my single 100k CSS file. Reducing javascript and deferring the rest gets some solid speedups. Serving everything from a single domain reduces total load time, due to DNS lookups. You might even get away with not having social media widget JS, too: https://www.hanselman.com/blog/add-social-sharing-links-to-your-blog-without-widget-javascript https://www.hanselman.com/blog/add-social-sharing-links-to-y... [0] https://theandrewbailey.com/ https://theandrewbailey.com/
- kevincox 4y agoIn my opinion very few if any sites need fonts. The user has a default font, who am I to say that I know a better one? If you want to be more pragmatic you can accept that most browsers use awful fonts by default. However coming soon is system-ui, ui-serif and ui-sans-serif which allow you to let the user to continue picking the font, expect not awful. (I still don't understand why browser didn't just update initial, serif and sans-serif to be non-awful, but I'm not a browser maker)
- SquareWheel 4y ago> The 3 that my blog[0] uses are base64 URLs in my single 100k CSS file. This is not an efficient approach. Base64 will make the fonts about 30% bigger, and webfonts are already too big. The fact that it's in CSS also means that it's now render blocking, and font-display can't be used. You're likely delaying your render time versus standard font loading. Do a comparison in WebPageTest and examine the waterfall.
- Schroedingersat 4y ago> Base64 will make the fonts about 30% bigger, and webfonts are already too big Does this actually change the transmitted size significantly?
- theandrewbailey 4y agoAfter gzip or brotli, the increased size of base64 is negligible. That 100k CSS is less than 70k compressed.
- SquareWheel 4y agowoff2 is already a highly-compressed format so you shouldn't expect much in terms of savings. Maybe gzip could offset some of the fat added by base64 though. 100KB for a font is a lot of data on a website. I'm using a custom subsetted version of Source Sans Pro at just 6.7KB.
- wrycoder 4y ago2014, but useful.
- orkj 4y agoI feel it's relevant to mention this post is from 2014 (reference: how I interpreted the archive at https://danluu.com/ https://danluu.com/)
- jeffbee 4y agoThe lack of dates anywhere on that site is a continual low-level nuisance. Does anyone know what doctrine prevents having dates on these articles?
- ag56 4y agoGoogle? Older articles are down ranked? A guess.
- helij 4y agoI bet Google 'knows' the date page first appeared in its index.
- bombcar 4y agohttps://twitter.com/danluu/status/1521583578856902656 https://twitter.com/danluu/status/1521583578856902656 > This comment is a nice illustration of why I don't have dates directly on posts and "make" people click once to get the date. > This has been an issue for decades. The fact that it's an old issue makes it more important, not less. > https://news.ycombinator.com/item?id=30935064 https://news.ycombinator.com/item?id=30935064
- kelnos 4y agoThat tweet seems to contradict itself. If it being an old issue makes it more important, than isn't it also important to call out that it's an old issue? Sure, a date (in the far past) on the post might make people question if the issue still exists, but also points out how long the issue has been around.
- mjw1007 4y agoSo it appears his opinion is "If I arranged things so that readers could easily find out how old my articles are, some people would ignore them even though they still contain some useful content, so I will try to hide this information". My opinion of that is low.
- daniels1006 4y agoPretty cool! That's offensively fast by 2022 standards.
- bombcar 4y agoYeah, wow, I was instantly surprised how fast it loaded.
- deleted 4y ago[deleted]
- posharma 4y ago@danluu: How do you find time to write a detailed post like this outside your day job?
- jessermeyer 4y ago"I'm not going to try to convince you to start writing a blog, since that has to be something you want to do, but I will point out that there's a large gap that's waiting to be filled by your knowledge. When I started writing this blog, I figured almost no one would ever read it; sure Joel Spolsky and Steve Yegge created widely read blogs, but that was back when almost no one was blogging. Now that there are millions of blogs, there's just no way to start a new blog and get noticed. Turns out that's not true." - Dan Luu https://danluu.com/about/ https://danluu.com/about/ As of late he is also supported on patreon: https://www.patreon.com/danluu https://www.patreon.com/danluu
- googlryas 4y agoI have no idea who dan luu is, but I imagine he does something very similar for his day job.
- bombcar 4y agoThere's a number of people who can take what they do in their day job and then write about it (this example clearly is not that, but he spend 30 minutes speeding up his site, and probably an hour documenting it; that's less time than many of us will waste on HN today).
- bachmeier 4y ago> that's less time than many of us will waste on HN today It's impossible to waste time on HN.[1] [1] That's what I keep telling myself.
- kelnos 4y agoDan Luu's posts show up here pretty often. His posts are generally well thought out and often involve quite a bit of research and deep-diving into whatever topic he's chosen to write about. He doesn't post super often -- a quick perusal of his archive shows at most 3x per month, often less, and often not even once during a random month. So while each post might take a lot of time and effort, it's often spread out over weeks or more. (Not trying to criticize your lack of knowledge here, just aiming to fill a knowledge gap.)
- kris-s 4y agoI run a few websites on a single Linode, they're quite snappy if you don't do too much. No fancy optimizations required, just keep it vanilla, you can make great websites with just modern HTML, JS, CSS: https://krisshamloo.com https://krisshamloo.com I'm sure it's been posted to HN before, but I love this blog post about it: https://idlewords.com/talks/website_obesity.htm https://idlewords.com/talks/website_obesity.htm
- masswerk 4y ago> What if we move the scripts to source/_includes/custom/after_footer.html? Please don't do this, this is the slowest possible way to load these resources and the longest duration possible until a fully interactive page. Use "async" or "defer" attributes instead.
- lelandfe 4y agoFootnote: if the scripts are not necessary for interaction, moving them to the footer and marking them deferred/async allows you to prevent the browser preloader[0] from being too eager with downloading them during downtime. This is effectively a poor man's resource priority hints[1], allowing the developer the ability to prioritize downloads for the browser. [0] https://andydavies.me/blog/2013/10/22/how-the-browser-pre-loader-makes-pages-load-faster/ https://andydavies.me/blog/2013/10/22/how-the-browser-pre-lo... [1] https://wicg.github.io/priority-hints/ https://wicg.github.io/priority-hints/
- masswerk 4y agoYes, the end of the document + `async` is probably still the way to go for analytics scripts and similar things. (`defer` will still block the initial render.)
- lelandfe 4y agoOther way round. Neither blocks parsing/render during downloads, but async scripts execute immediately onLoad – blocking render. defer "defers" that until after document parsing is finished. https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/What_is_JavaScript#async_and_defer https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Fi...
- swyx 4y agowell yes but also did those attributes exist in 2014? (genuine question, i dont know)
- deleted 4y ago
- zui 4y agoThis was in 2014. Now the page load even faster ! Related post from his blog: https://danluu.com/web-bloat/ https://danluu.com/web-bloat/
- kelnos 4y agoThis is really funny to me, because I generally view danluu.com as a pretty clean, "low design", low-complexity site, so it's odd to see how complex it actually is. (Or at least was, since this is an old post; the current version seems to be much lighter.) Also I'm now realizing that it's a bit silly to call things like these "static sites". Sure, it's not backed by a database, but it's by no means "static". The entire point of Javascript was to make web pages more dynamic! If you're loading and using JS on your site, it might be "statically generated", but it's certainly not "static".
- dylan604 4y ago"static" was more of the server side requirements than if it's interactive or not. like "static" sites that can be hosted serverless from an S3 bucket.
- LukeShu 4y agoI tried using the Wayback Machine to see what it looked like back when this article was first published, and discovered that danluu.com has been excluded from the Wayback Machine.
- hyperpape 4y agoThis all refers to an old design. Curl danluu.com today, it's a single file HTML page.
- mattlondon 4y agoIs the "finite connections" thing even a thing any more? As far as I understand things, HTTP/2 kinda solved that problem (within reason) and you don't have to worry about combining JavaScript and CSS and images etc into giant bundled files so much any more?
- matsur 4y agoYou still have to worry about head-of-line blocking across streams with H2. HTTP3 promises to really really fix these issues.
- Simplicitas 4y agoIt's time for everyone to put the date at the top of every document.
- rawoke083600 4y agoagreed ! And filenames to code-snippets !
- andai 4y agoIs it really true that the page originally took >10s to "start rendering", or is that an artifact of the way it's measured? Was the page literally blank for ten full seconds?
- deleted 4y ago[deleted]
- nickjj 4y agoDoes anyone have a hunch on what caused the 100ms reduction in the time to first byte? Is it just having a much better and broader spread on where Cloudflare has datacenters serving DNS lookups?
- grayrest 4y agoThe site was moved from a host that got a D rating on TTFB from whatever precursor to lighthouse he's using here onto an edge cached CDN. I expect the distance to server is helping but most of the improvement is from github pages having a pretty substantial built-in slowdown at the time (this is a 2014 article).
- deleted 4y ago[deleted]
- MrYellowP 4y agoIn the long run they would have been better off just coding it all themselves with the purpose of efficiency in mind, instead of relying on work of other people. The biggest misconception I've found, to date, regarding performance, is that people believe everything's fast, because a compiler/JIT makes it fast. Only a small percentage of programmers actually know how to do things right, the rest of every-thing is built up upon the same nonsense everyone gets to not just learn, but also gets to spread it even further out, creating a faulty norm everyone just accepts as true, because everyone says it's true. Fact of the matter is that, as an analogy, a garbage collector is pure and utter nonsense, because it's a bandaid to fix the issue with people having no clue how to actually handle memory properly. Instead, they believe garbage collectors are a good thing, while also struggling with it interfering when it shouldn't. To extend this analogy: Everyone would be better off just learning the simplicity of handling ones memory by ones self. Making at least ones own library for proper memory handling and management once, should be mandatory. It's not that far away from "proper memory handling" to "setting up and accessing data in a cache efficient manner" ... and further.
- giantrobot 4y ago> Everyone would be better off just learning the simplicity of handling ones memory by ones self. I've found the difficulty of memory management increase quadratically to the linear increase in program complexity. So simple programs have simple memory management and even modestly complex programs have very complex memory management.
- 5cott0 4y agonow do margins
- togaen 4y agoThe tl;dr of it is: get a fast host, don’t use JavaScript, and don’t use web fonts. The web will never be as fast as it was in 1999.
- digisign 4y agoIt can be faster if you combine the best of the old and new.
- throwaway0asd 4y agoMy personal application is the front half of an operating system written in JavaScript (TypeScript). The browser portion fully loads with render and state restoration in about 175ms according to the Chrome performance tool in the dev tools. That JS is about 380kb unminified bundled into a single file. The CSS includes 2 custom fonts in base64. The Node side of the app loads a bit slower in about 250ms but it’s also executing about 10x more code.
- thewebcount 4y agoI had a chuckle at this note: > First, it seems to likely show that the advice that it's very important to keep line lengths short is incorrect since, if that had a very large impact, it would've overwhelmed the other changes and resulted in reduced engagement and not increased engagement. Well, I can't speak for anyone else, but I read all articles on that site with Reader view since they're impossible to read any other way. There's good content there, but man is it a pain in the ass to read!
- bribri 4y agoYeah I appreciate what he’s trying to do with the minimal brutalist web design but I need a Reader view to make it through the content.
- pwillia7 4y agoI barely made it through on my ultra wide monitor and was mad when he said no one cared -- I DID! But to his credit I did read the entire article.
- taftster 4y agoShouldn't that somewhat be the point, though? Shouldn't we have control over the look & feel, layout, design of the websites we visit? I'm feeling like you did exactly what you should have done. You chose to read the site in a style (Reader Mode) that benefits you. Maybe someone else chooses a style, set of fonts, or overrides the margins manually. I think we've gone too far with HTML styling. I'd much prefer unstyled semantic markup and then let my theme choices display the content. Early HTML was quite a bit more like this. Gopher protocol and Project Gemini might be other examples of content without "design."
- wahnfrieden 4y agoYou’re just saying user defaults don’t matter
- hombre_fatal 4y agoNow consider how much time you want to spend configuring every website you click in to from HN because they have bad defaults. That’s probably zero. Why would you even make people have to take an extra step to comfortably read your content?
- kristianp 4y agoIs webpagetest still a good way to test web performance in 2022?