開源日報 每天推薦一個 GitHub 優質開源項目和一篇精選英文科技或編程文章原文,堅持閱讀《開源日報》,保持每日學習的好習慣。
今日推薦開源項目:《需求帶動發展 FaceMaskDetection》
今日推薦英文原文:《You Don』t Need a JavaScript Framework》

今日推薦開源項目:《需求帶動發展 FaceMaskDetection》傳送門:GitHub鏈接
推薦理由:眾所周知,人類有不少需求就來自於懶惰,正是因為懶才會有那麼多方便的小玩意;現在有不少需求則來自於疾病正在蔓延的現狀——關於口罩的需求自然就出現了。這個項目是人臉識別的口罩特化版,實現了識別人臉是否佩戴口罩的功能,畢竟這種時候比起誰是誰的問題,大家更關心他們有沒有防護措施,出去的時候還是注意保護自己為好。
今日推薦英文原文:《You Don』t Need a JavaScript Framework》作者:Dev by RayRay
原文鏈接:https://medium.com/better-programming/you-dont-need-a-javascript-framework-df2a36c2dd0a
推薦理由:殺雞焉用宰牛刀

You Don』t Need a JavaScript Framework

Sometimes React, Angular, or Vue.js might be too much

Do we suffer from JavaScript frameworks fatigue? Or are we ignoring the performance and data bundles of our users?

Let』s Go Back to the jQuery Era

Do you remember those days when everyone used jQuery for everything! jQuery before, jQuery after, everything smelled like jQuery. Every website or web application included jQuery.

Why?

Developers found Vanilla JavaScript was too difficult or complex to handle. There where a lot of big differences between browsers.

Thank God those days are over! jQuery fixed a big problem for the JavaScript community. But it made most of us lazy because we didn』t understand what was going on under the hood.

For me, it all ended when this website(http://youmightnotneedjquery.com/) launched.

The JavaScript Fatigue Era

Right now, 2020 is just starting but we are making overweight websites and web applications. We can choose Angular, React, Vue.js, Svelte, or Polymer. Sorry, I won』t name all of them…

Maybe you』re thinking: 「Well, go ahead and judge for yourself.」 Well, that is also what I』m doing with this article. I』m very critical about my own JavaScript fatigue.

But let』s be honest. It has never been easier to start a website or web app from scratch with a single command. For Angular, we use ng new project name, for React we use …, etc.

Most of the time, we are picking what suits us the best. But we have to decrease our JavaScript weight some more and be more thoughtful on what we load into our application.

Because, maybe HTML, CSS, and JavaScript are enough.

When I talk about the JavaScript framework, I also mean the JavaScript library. Angular, React, Vue.js and Svelte are for me in this category. (Yes, there are a lot more…)

Pros and Cons of Using a JavaScript Framework

Using a JavaScript framework has some pros and cons. Because it』s about good and evil. It』s more like one』s better in one situation than the other.

I』m using Angular in my day job and like to experiment with React or Vue.js. Or trying some small JavaScript micro-library that does only one thing very well.

When You Shouldn』t Use a JavaScript Framework

There are a few situations I won』t recommend using a JavaScript framework, but rather recommend using a JavaScript micro-library or use Vanilla JavaScript.
  • Your application is simple or small. If you』re building a small project, such as experimenting with a new JavaScript API.
  • Tight on performance. When your application needs to be of very high performance, even on a low-bandwidth connection.
Every byte that is sent over the line counts. Then, it』s not smart to use a big framework. Because a JavaScript framework comes with a cost because of its overhead.

Well, there are many tools to make this more manageable. It』s better to prevent problems than to solve them.

When Would a JavaScript Framework Be a Smart Choice

There are situations where it is smart to use a JavaScript framework. But still, we need to be careful with everything.

1. Your application is big

When you』re building a big application, it could be smart to use a JavaScript framework. A framework, most of the time, comes with great support from a community.

Most of the time, a community will provide a lot of learning material that helps to build an application for long-term support.

2. You or the company values open source

The best thing about open source is that everyone can use it how they want (if the license allows it of course).

A lot of the elements of that framework are built by people that spent their free time on it. This doesn』t cost the developer or the company that is using it any money.

If a company/developer likes to contribute to a JavaScript framework, other people can benefit from that too.

3. High speed development for new features

Because most frameworks offer a lot of tools they make it easier for the developer to build new features in shorter times, they can rest on the shoulders of smart engineers that did a lot of testing for them.

Conclusion

In my story, I have more pros in comparison to cons when we talk about JavaScript frameworks.

But even though it sounds so good to use a framework, we have to be very careful with what we load onto our websites and application.

Always ask the question: 「Why do I need this framework? What benefit would we have from building it ourselves or using something that already exists?」

「What consequences does it have for the user? Is a low-end mobile phone also able to use the application with the same user-experience as a high-end mobile phone?」

Thanks

Thanks for reading all this way! I hope that after reading this story you will be more careful picking a JavaScript framework, or not picking one.

Because, in the end, our goal should be building an application that has great user experience and is scalable.
下載開源日報APP:https://openingsource.org/2579/
加入我們:https://openingsource.org/about/join/
關注我們:https://openingsource.org/about/love/