Skip to main content

sometechblog.com

How to dynamically load Stripe with NextJS

I was checking the performance of one of my web sites using Page Speed and noticed it complained about assets loading slowly as well as the initial response time from the server being a bit long (500ms-700ms range). My first thought was that it might be the database queries being too slow. I quickly ruled that out (they all took in the vicinity of a few milliseconds).

Then I noticed Stripe was loading on each page load. This only happened in production hence I didn’t noticed it while developing the site. I tried disabling “prefetch” on links to the pricing page but that didn’t help. Stripe library was still being loaded on every page load. Apparently NextJS bundles libraries in this fashion, so looked into dynamically loading Stripe.

Macbook Air M1

I had no idea what would happen to me that day. It was my last day working for a client in Berlin. I came to the office to work and have a small goodbye party on the sunny terrace. This was the first time in the psychical office, before that I have, like almost everybody else, been working from home.

I had bought my laptop just a year before. It was the most expensive Macbook Pro 16" with 8 Intel CPU cores and it costed 3600 €. It was quite an investment. It was driven by the theoretical argument that if I save just 10 min a day it would, given my high salary, it would pay itself off. With an hourly rate of 100 €, 10 min is 16€ a day. That is 80 € a week and 320 € a month. Utilizing this argument, I am sure many would be forced to upgrade to the newest Macbooks with M1 cores. And likely again with the arrival of the improved M2 cores.

Setup Sublime Editor for Writing

Sublime Editor is build for writing and reading code. However the urge to write down your thoughts on different matters might come and for this Sublime Editor offers excellent support. Both out of the box and with a few useful packages.

Opposite to coding, where concise code blocks and programing logic becomes more readable through highlighting and linting tools, writing is easier with fewer colors, larger text and line height.

Redux is too complex

Redux is a popular library used to manage global application state, at least the claim. Lots of developers struggle to understand what Redux does and how to use it properly. When saying global state most developers would intrinsically imagine a simple library lifting up individual states into a shared global object. This isn’t Redux. Although Redux is a small library (2kB, including dependencies), the documentation and the complimentary libraries required makes it comprehensive. For experienced and inaugurated developers redux.js.org it’s a well-written and detailed guide that covers every aspect of Redux, for others it’s opaque and overly complex. An complexity that is also increasing present in React and which the upcoming Svelte framework highlights.

Questions to ponder before a JS job interview

It’s that time again where I have to prepare for job interviews. Since companies aren’t looking quirky originals, you need to learn what to say to look attractive. And have some answers to the common questions.

#### How do you approach complex problems?

There isn’t one approach since complex problems are different. Here are some common ones:

  • structural/architectural problems as the application matures should be handled together with the team, since everyone has a stake in the app and should be heard. These problems arrives gradual and shouldn’t be handled with rash abstractions, but rather initial observance so that there is enough foundation to assess the problem on. Thus the problem will likely be fairly well known to team members before a meeting. Give some thoughts on possible solutions before, call a meeting and listen to input and solutions from team members.