checkout my Questions & Answers section for DEVs,
see if there's anything you like 😈
Search shit with Ctrl+F
I'm too lazy to make a search engine for you
when i add new data in prisma schema, should I create a new branch on git to push inside?
Everything you do is in your own feature branch.
When you think your branch is ready create a pull request,
Hello friends, this is a rather retarded question, but why wouldn't we want to use lazy import in ReactJS every time instead of normal import?import component from '../'
vs const component = lazy(() => import('../'));
There is a fairly detailed explanation here, I'll summarize and also add another point from my own experience:
Summary: lazy import will create a lot of network requests for you and basically load your code more slowly, slow loading = crap doo-doo poop!
Bonus point: lazy import is a relatively new technology and not super stable for production; sometimes it just so happens that a network request fails, and if it were to happen when you have loaded one part of the code but the other part failed to load... You will get an unexpected error and the behavior of your application will brake.
And when I say brake, I don't mean a white screen crash, I mean you'll get an unexpected behavior, and that's worse than an app that crashes classically with an error message or a white screen. It's better to fail on the first request and have everything go to shit than to have something go to shit halfway through. Remember I said it's not exactly production ready? Well, your browser also agrees with me, because what the son of a bitch does to you when your request fails is to cache the failure! and then even if the user refresh the page it will get stuck in the same state! which is not just shit, it's super mega duper shit in production.
I still can't forget the late night call I got from the CEO of the company I worked for when this happened to him in the middle of his demo and he insisted that it was my problem that I needed to fix it pronto... And if you think you might have a chance to handle this problem, let me disappoint you; Because not only did I try every trick in the book, I also went to github and complained there, and guess what... 3 years later, the github issue is still open =) good luck
Also, your question is Not retarded by the way. There are no bad questions, just bad answers.
Friend, I appreciates the detailed answer, good to know. So all in all, based on your experience with it, you recommend not using it? and just knowing that it exist? lol
There is a lot of benefit and goodwill in dynamic imports, there are also disadvantages and some of them are dangerous and you need to know them when using it. When do I recommend using it:
What I suggest to you is not use dynamic imports by default. Only when you see that your application is becoming heavy and slow will you start thinking about splitting your code into chunks. If you use something like nextJS
, you will get automatic code splitting by pages "for free" because it is one of the most logical places to do it without thinking too much. Nevertheless, it is good to know that it might cause you problems if you have a flow with several pages. In other places, think carefully before using dynamic imports, and it's better to think as little as possible. In other words, don't think about splitting something before "not splitting" it, hurts you a lot.
Another small thing that may have been missed here, when you write a dynamic import, your bundler has to decide what to do with it. Depending on its configuration and the bundler itself, usually, if you push a lot of dynamic imports to your code base, the bundler will ignore them and in practice it will only make a few code splits in order to avoid unnecessary network calls. So if you bombard your code base with these dynamic imports it doesn't really make much difference. You have to take into account the behavior of the bundler, who is usually smarter than you and will prevent you from doing stupid things. If all this shit sounds like a big mess that's better off not thinking about, I agree with that line of thinking. Don't think about it until you have to =)