When you’re about to start a new website, what do you think first? Do you start with a library or framework you know, like React or Vue, or a meta-framework on top of that, like Next or Nuxt? Do you pull up a speedy build tool like Vite, or configure your webpack?
There’s a great tweet by Phil Hawksworth that I bookmarked a few years back and still love to this day:
Your websites start fast until you add too much to make them slow. Do you need any framework at all? Could you do what you want natively in the browser? Would doing it without a framework at all make your site lighter, or actually heavier in the long run as you create or optimize what others have already done?
I personally love the idea of shipping less code to ultimately ship more value to the browser. Understanding browser APIs and what comes “for free” could actually lead to less reinventing the wheel, and potentially more accessibility as you use the tools provided.
Instead of pulling in a library for every single task you want to do, try to look under the hood at what they are doing. For example, in a project I was maintaining, I noticed that we had a React component imported that was shipping an entire npm package for a small (less than 10-line) component with some CSS sprinkled on top (that we were overriding with our own design system). When we re-wrote that component from scratch, our bundle size was smaller, we were able to customize it more, and we didn’t have to work around someone else’s decisions.
Now, I’m not saying you shouldn’t use any libraries or frameworks or components out there. Open source exists for a reason! What I am saying is to be discerning about what you bring into your projects. Let the power of the browser work for you, and use less stuff!
I made the decision a few years ago to go full vanilla on future projects and started writing libraries myself to handle functionality I used daily. Not having to import jQuery and a myriad of other libraries that weigh down the site right off the bat has been so nice!
Was super happy to set my site up with a popular CMS instant install, use a JS-less theme, and run it with a static / varnish plugin.
Was up and posting within minutes, with no server-side anything for users.
I appreciate the point made here. I’ve always built my sites from scratch and avoided using (or learning) frameworks. I created and maintain a local cemetery site that cannot pay me or anyone else for what I do (a labor of love that keeps me learning). My design is basic for the intended audience, but I have more on my ToDo list for UX. Now that I am 70, the realization that I need to hand this off someday looms (hopefully not until my 80s). So now I worry that I should have used WordPress so that it can more easily be handed over to someone. But my only experience with WordPress has been to patch websites that were built with it in which the designers are long gone and left no documentation for their clients.
As you said “Open source exists for a reason!” and small startups doesn’t have enough resources or time to build even the small piece of code sometimes.
The key point here is to try to isolate the 3rd party libs as much as possible in an effort to replace it by your own better and optimised code in the future.
Although sometimes, creating this interface to isolate it may be more effort than building the solution by yourself.