753 points · by cheeseblubber · 3y ago · 209 comments
> We found that react-icons had an issue that lead to everything being imported. This meant that we were including every single react-icon in our package whether we need it or not.
Kudos to the Linen team for proactively finding this - I have a feeling tons of projects blindly trust that tree-shaking their dependencies will "just work" even though for many libraries it won't!
> We also noticed that we were only using AWS client for s3 upload on the client side and it was taking up significantly more bundle size we need so we replaced the entire client side package with a 2 api calls to the AWS api.
For such a minimal use case, this feels like a logical choice even if it's slightly more work to implement.
> We ended up moving the code highlight code to a backend api that would cache the results.
Love seeing websites make smart choices about which work to handle in the server versus the client.
They provide a full framework but you can also download SVGs.
ex, an s3 only Java sdk:
https://stackoverflow.com/questions/35591248/aws-sdk-for-s3-...
You need to have two calls at least, generate a signed URL and then actually uploading it. How many lines on the client would you guess that requires? My guess is less than 30, and you cover 100% of your use case without putting in any 3rd party code what so ever. Sounds like a solid win with few drawbacks.
Any possibility of you sharing your "codemod script" so others can potentially implement it too? :)
For one particular microsoft product, this is brought to attention by documentation: https://learn.microsoft.com/en-us/power-apps/developer/compo...
Is there an easier way to verify this than, say, observing the final bundle size and looking inside the JS bundle? I'm not a frontend developer so this is outside my usual area of knowledge.
[source-map-explorer]: https://github.com/danvk/source-map-explorer
[Lighthouse Treemap]: https://umaar.com/dev-tips/270-devtools-lighthouse-treemap/
I notice that if I lower the bar and allow half baked hackish solutions to slip in, beyond some point, upkeep consumes infinite time. There seems no way back from that besides starting from scratch.
There is no good reason for front end things to break. I can only think of document.writeln() but who in his right mind...
The intro community discussion page at https://www.linen.dev/s/linen does need to load 20+ javascript files for some reason to show the latest messages.
Whereas messages still show up even if javascript is entirely blocked, just starting from the beginning in 10/2022 (?).
So I'm not quite sure if it's as optimized as it can be.
What tool did they use: Browserify, Webpack, Gulp, Rollup, Babel, Parcel, ESBuild, etc.
And this looks like the PR for the icons update: https://github.com/Linen-dev/linen.dev/pull/1001
Always fascinated when I hear that JS term for what's essentially dead code elimination.
Tree shaking only looks at the imports and removes code that isn't imported from the bundle. If code is imported but not executed, then tree shaking won't remove this code, even though it is dead code.
Using a different term is reasonable to avoid confusion, in this case.
It's usually a call you need to make based on what you're shipping, but at the very least, it'll ensure you don't blow up your performance because something slipped by.
Finally, looking at the components of your bundle if you haven't already is well worth it. Like the people over at Linen noticed, they were shipping a ton of icons they were never using. This is happening all over the internet, and it's a real drag on the network, parsing, and executing phases in a browser. If you benchmark, you'll see significant differences when you trim things back.
If you have customers using lower powered devices, this is even more crucial.
You can get a feel for what it looks like here on an active project here: https://app.relative-ci.com/projects/TMqufq6bi8qzsOjEHSWY – but mostly you end up using the status pushed to GitHub PR's
I totally agree with the need to run bundle analysis checks often for medium/large-size applications. It will help to notice the issues when they are introduced, otherwise, the optimization task becomes really challenging. Actually, I built bundle-stats & RelativeCI after spending weeks on optimization tasks running hundreds of slow builds, staring at multiple webpack-bundle-analyzer reports, and using google spreadsheets to track asset/module changes.
One thing I noticed in the last 2-3 years is that we got better as an industry at managing the bundle size bloat: - improved libraries - new light versions for popular libraries - new and improved bundlers - new and improved meta frameworks - better tooling & more resources
However, the web applications we are building now are larger and more complex than before, with hundreds of bundled libraries and tens of thousands of modules. The increased complexity has made the bundle analyzing and optimizing even more complicated. One of the most common feedback I received was to better integrate the bundle analysis and insights during the code review phase and allow developers to detect and fix the issues as soon as they are introduced: - [done] Pull request comment with bundle analysis insights & summary (https://relative-ci.com/documentation/setup/configure/integr...) - [in progress] pending/approve/reject review flow based on custom rules
Google-Searchable and community focused
Slack alternative
Sync your Slack and Discord conversations to Linen and get SEO benefits while reducing customer support loadThe latter sounds like I need to be a Slack or Discord user, and Linen makes the conversations searchable on the web. But the title (Slack alternative) makes it sound like I can use Linen instead of Slack.
Which is it?
The issue is the public side of projects that are using Slack or Discord to answer questions. Those questions have to be answered again and again by the poor employee instead of the answer being searchable (via Google, or other search engine).
god it's HARD to search on discord.
After spending some more time it seems to be a chat app that allows importing.
One very minor friction point with Linen was, it needs to be a bit transparent about their pricing for business tier. I don't think "contact us" pricing strategy is the perfect fit Linen's target audience.
We just shipped our self checkout flow last week: https://github.com/Linen-dev/linen.dev/commit/61c482cab5d5aa...
Just hadn't got the chance to update it on the landing page yet
congrats on making the right choice
For anyone interested in HN-type forums (with lots of other features we've built)
Obviously HN+ is missing the single most important thing about HN, the users.
Also, did you really have to steal the name too? Would probably been better off if you called it something different.
By the way, you should read your own terms of service and maybe start following it yourself if you ask others to follow it too?
> Your site is not getting advertised via unwanted electronic messages such as spam links on newsgroups, email lists, other forums and web sites, and similar unsolicited promotional methods;
> Your site is not named in a manner that misleads your readers into thinking that you are another person or company. For example, your site’s URL or name is not the name of a person other than yourself or company other than your own; and
This is more of an IRC/forum alternative to me (which Slack originally was) until it is possible to use Linen instead of Slack.
Or just as a Slack plugin for the public Google search aspect - but this is absolutely incorrect to call it a Slack alternative for anyone who is using Slack as Slack. Things video/screen sharing/drawing huddles, integrations, SSO and permissions, slackbot, OCR search, notification settings etc aren't just a different of features - it makes it a different platform and tool entirely and solve different problems.
Expect this to become a paid offering at some point.
Initial and middle Investors kept passing the pie to the next bigger fool and the last bigger fool is now stuck with a very expensive web property desperate to recoup the investment let alone a 10x return.
Sounds like a Bitcoin food chain.
And then - aggressive monitization, price hikes staff cuts, SLAs adjustments etc.
On a general note I think you should link back to your landing page from the navigation of a project. Especially if people enter via a search engine, they are essentially locked within an organization. The only way out is to manually navigate to linen.dev.
Zulip is the only software I've found where you can catch up on weeks of conversation extremely quickly. It's fantastic. I never felt that I lost messages, unlike Slack, and it's very responsive, again unlike Slack.
I wish all the locked away Slack communities would use Linen[1] because there are so many nuggets of bug-fixery buried in Slack that will age off or never be found in the horrors of Slack search
1: I really wish they'd just stop using Slack entirely since Zulip is open source and bundles this "allow search engine indexing" built-in, but I think that ship has sailed
There's also the tangential fact that open source shouldn't be relying on proprietary communication protocols that are difficult to migrate away from or make it difficult to maintain anonymity.
Do people consider Slack search subpar?
I haven't used a chat app with a better one. Discord is abysmal by comparison
Web client is responsive and has good shortcuts.
Easy-ish to self-host, cheap to buy hosted.
Configurable privacy.
Integration with all sorts of stuff, including email.
A little lacking in community moderation tools.
Text-mode client works acceptably well over a low-ish bandwidth connection.
IOS and Android clients.
Open source.
We had an IRC server. IT and Ops used it.
We moved to ejabberd. IT, Ops, and a couple of devs used it. Not all.
We moved to Zulip. Everyone in the company uses it.
And, perhaps most relevant to my complaint, they offer hosting for open source projects (unlike Mattermost which is ... like, "send us email and we'll think about it" or something). I would guess Mattermost would feel the most comfortabe to Slack users, since I admit that Zulip has a different mental model than Slack, but I believe it is much better for ongoing thread management once one gets used to it (IOW, had they won the fight, it would be Slack that would be the "eww, what is going on with this threading model?!")
---
https://github.com/zulip/zulip#readme (Apache 2!) just as a contrast to the sibling's LMGTFY comment :-(
Nothing sounds like that big a deal unless you seriously try it in a company setting. I tried it once and there's no going back, I miss it every time I have to use Slack or Discord.
I haven't used it yet, but in general excited by projects like Linen and Zulip. I hate Slack and Discord (I love the web, deep links, and indexability/searchability)
In my experience, Google search results are poor these days, prioritizing esoterica or blogspam instead of useful insights due to decades of SEO battles. I prefer to hear what folks I'm directly interacting with are saying when they make a recommendation instead of jumping to the old "LMGTFY" silliness we all smugly passed to others circa 2008 who forgot to RTFM/RTA.
import hljs from 'highlight.js';
pulls in over a Megabyte of hundreds of programming language syntax definitions.Do you really need Mathematica, "ISBL", and "GML" — or would a curated list of popular programming languages such as Python, Java, JavaScript, and HTML ("xml.js" ) be enough? This results in a massive reduction down to ~70 kilobytes.
Even better: load this reduced size of highlight.js only on demand, leveraging Webpack's "import(..) to webpack chunk" mechanism:
const getHighlightJs = async function() {
let result;
if (window.hljs) {
result = window.hljs;
}
else {
result = (await import('highlight.js/lib/core')).default;
const javascript = (await import('highlight.js/lib/languages/javascript')).default;
result.registerLanguage('javascript', javascript);
const xml = (await import('highlight.js/lib/languages/xml')).default;
result.registerLanguage('xml', xml);
// xml provides html/html5 highlighting
window.hljs = result;
}
return result;
};
const lazyHighlightAll = async function() {
let result = null;
// see https://highlightjs.org/usage/
// highlight.js's hljs.highlightAll() matches on 'pre > code'
const hasHighlightableCode = document.querySelector('pre > code') ? true : false;
if (hasHighlightableCode) {
const hljs = await getHighlightJs();
hljs.highlightAll();
result = hljs;
}
return result;
};
document.addEventListener('DOMContentLoaded', function() {
lazyHighlightAll();
});The one you complain about is specifically about importing everything, because that's what the user wants in that case, importing it like that signals that that's what the user wants.
Otherwise you can do the following:
import hljs from 'highlight.js/lib/core';
import javascript from 'highlight.js/lib/languages/javascript';
hljs.registerLanguage('javascript', javascript);
Maybe the defaults should be different, but a 30 second read of the most basic information available in the repository would reveal how you can use it the way you want too, without any complication that the rest of your comment seems to want to introduce.They'd move begin searching for a new solution.
Some would recognize they should substitute their language.
Then a tiny fraction of users will actually read your documentation :)
76K node_modules/highlight.js/lib/core.js
20K node_modules/highlight.js/lib/languages/javascript.js
But I agree with you, that you probably want to only load it when really needed, especially if your total budget is 500kb which this would take a big part of it already.Edit: I see now their budget was actually more than 1MB actually, as they for some reason only "really care" about gzip'd sizes... Then I wouldn't say it's so bad to just say fuck it and do it the easy way. Saves any latency introduced by lazy-loading it too.
The two different variants written are six of one half a dozen of the other. There's nothing stopping you from writing the imports + register in one file and dynamically importing it in a dom loaded event in another.
disclaimer: OSS founder here that cares a lot about managing community!
We think that there is a better chat app out there that isn't built yet that handles things like: 1. A non chaotic notification system. Slack and Discord stresses me out. We want to introduce things like !mentions which sends you a push notification and @mention notifies you but doesn't interrupt you. 2. Better thread and content management. Things can get messy in Slack and that you can't find information. We give you ability to move threads and messages around to help organize that and we want to do more to help people find content. 3. More power user features: Slack is probably the most used app for a lot of us and I don't think it is optimized for individual productivity. We want to build something that is designed for our productivity. Something along the lines of Linear or Superhuman.
apples and oranges?
Also, I seem to recall there was some drama about if one used Ripcord against a Discord server, it resulted in your account getting banned
while(1) malloc(1000);
Is only 0.02kb and will bring your computer to a crawl.
Meanwhile I can just write a IRC client in C that's less than 100kB.
As somebody that used irc a lot in the day, it's ridiculous to suggest that a protocol that doesn't even save chat history is being compared to the feature rich chat apps of today.
They're also much more wasteful of resources, and needlessly proprietary ecosystems.
I'm going to put Linen on my list and I'm curious to see where it's going. The concept of a searchable alternative to 'closed' communities like Discord is promising.
I'm wondering, though, if it's essentially a real-time chat experience that perhaps focuses on speed rather than depth.
I only realised this after reading your comment. That was an unexpected/pleasant surprise.
I found a 'typo':
> Get branded colors and logos of your community or company. Your community should feel like yours and not
The sentence does not
Slack is mostly IRC with persisted history and threads.
Do I really need all these API keys for s3, sentry, push service, ngrok, etc to run a web app on a home network?
can it replace slack basically ? what will i have to do ?
I'm probably too dumb. clicked some 20 places and still nothing. only find their unlinked to source marketing nonsense "Linen is an open source".
Want a lean Slack alternative? Use IRC. Want a fancy Slack alternative? Use Matrix.
I want rich messages, images, links.
I want threads.
Given that we're talking about search-engine-visible logs - just use an existing, public server.
> I want my messages to be synced between multiple devices including mobile ones.
I actually believe it's better for people _not_ to have Slack on their mobile, so as not to be pestered, but if that's what you want, then you want the "fancy" alternative. Matrix clients can offer you that.
> I want rich messages, images, links.
So, Matrix.
> I want threads.
If that's the case, maybe what you really want is a Discourse web-forum rather than Slack.
Anyone has usable threads yet? For the life of me I can't follow Slack threads.
See discussion 7 years ago on serverfault.com, and the links therein:
How to set up a IRC server that logs all messages? https://serverfault.com/q/190069/113898
How to Offer Searchable IRC logs? https://serverfault.com/q/36886/113898
The bot option should be valid for Matrix as well, although there I'm not sure the bot world is well-enough developed to be 100% sure that a bot exist for every common desire like saving channel logs.
It's not too pretty though, but definitely usable: https://view.matrix.org/room/!SzcRUxcpYurpoctOzk:matrix.org
For me, the biggest barrier for adopting an alternative to Slack (or Facebook Messenger) is that no one else will switch with me.
It would be great if Slack could simply become an API for a chat client I prefer.
> Violating your privacy by sharing or analyzing your data is a criminal offence.
Uh, yeah. I don’t think that has ever stopped anyone. We have had companies literally spraying the personal info of all their customers all over the internet, and as far as I know they’re still running.
I’m in some communities who are currently looking for slack alternatives, that may not want their chats to be logged and shared online beyond the chat tool itself.
Page open:
Firefox: 18.5MB
Chrome: 12.1MB
After browsing:
Firefox: 27.14MB
Chrome: 11.7MB
Doing a heap snapshot will give you a better view of the page memory usage in isolation, without involving the browser itself.
Still, optimised code is cool.
find small packages for pagespeed metrics
serve 100mb of ads and analytics
It sounds like an exercise for a CS student's first TCP/IP program.
Is it just me, or does anyone else think that there's something wrong about the modern Web when a chat program taking 500kb (gzipped!) is an impressive technical achievement to be proud of?
It's something I didn't realized until I started coding it: every detail that you omit from your chat UX is a tragically noticable pain to the user used to WhatsApp and Slack 100 times a day.