当前位置:网站首页>What if the front end doesn't use spa? - Hacker News
What if the front end doesn't use spa? - Hacker News
2020-11-06 01:33:00 【On jdon】
A piece of 《 If the front end doesn't use SPA What can I do ?》 Initiate a discussion , This article discusses in addition to React.js Other frameworks :Remix,RedwoodJS and Blitz.js.
With Remix For example , It reconnects data loading with routing , And then he made an amazing promise , That is, no client data will be extracted by default . These frameworks also consider state codes and caching strategies .RedwoodJS Use GraphQL and Prisma Automatically create Be similar to ORM The interface of .
It is worth mentioning that Turbolinks.Turbolinks 5 The goal is : Without any application collaboration , get SPA What's the minimum you need to experience ?
This is a very small one JavaScript library , It sits on top of existing server rendered applications , And use something like SPA Part of the page load instead of the full page load . No need to load pages from scratch , But use AJAX Loading page , Replace page content , And the client navigation updates your URL. Basically , It prevents the actual page conversion from “ flashing ”, And it saves all the other costs of fully loading the new page .Turbolinks It's from Ruby on Rails Project derived , But with Rails Well matched , But it's not needed .
In terms of the weight of improving the user experience ,Turbolinks It's an outstanding product : It brings minimal complexity and small size impact to a complex user experience .
The article also mentions the server-side state framework : The main competitors are Laravel Livewire(PHP),Stimulus Reflex( stay Ruby on Rails Use in ) and Phoenix LiveView( stay Phoenix Medium Elixir Use in ). These frameworks are exciting , And extremely rebellious , Because they are associated with “ front end + I don't know API layer ” The pattern is the opposite , And they wholeheartedly accept things that everyone wants to avoid : Variable state on the server .
Various opinions :
From my first contact with Angular since , I've always felt this problem . Unless you want to make a real interactive asynchronous application ( for example Google Docs or Facebook Chat), Otherwise, it will become more complex and fragile , And it doesn't actually do any good .
When SPA Become the norm , You even need to use React When building a static web page , Development efficiency is also getting lower and lower . I see the whole team trying to build simple applications , And wasted months of time , These teams used to develop on a proven server-side framework with just one or two developers in a few weeks . however , It's no longer in line with best practices and industry standards . Everything needs to be SPA, Microservices , Distributed database ,Kubernetes etc. . These components and layers need to be bonded together through trial and error .
I'm glad that common sense is becoming popular , More and more developers are beginning to realize that integrated end-to-end frameworks are very useful for many real-world application development scenarios .
Interestingly , I find that the opposite is true . I've been working on front-end code for more than ten years , But I've never done it faster than now , There is also less error code written . Is that because I've become a better developer ? Certainly. . But on the whole , I don't think it's ultimately the reason . I think it's the maturity of the technology . My development as a programmer is hardly linear , In the past 5 Years ago with me 5 The growth in this is not matched . Front end tools have never been better .
I Believe , structure Web The threshold for applications has been lowered , And more programmers than ever before . You may not be developing and javascript Aspect attempts to construct complex UI And application experts . therefore , You've chosen someone who doesn't have the necessary experience , And use a framework that's really easy to use , Put them into quite a lot depth ( front end ) Working in a paradigm , But they can get into trouble by abusing these complex issues .
Another factor is , because SPA It's stateful , So complexity will surge . A page doesn't refresh stateless pages every few seconds , Instead, it leads to errors raising their heads during the duration of the conversation . These inexperienced people are responsible for designing a code base that doesn't scale and doesn't become spaghetti . however , If the design is reasonable , These problems will be greatly eliminated .
I'm not advocating SPA It's the way to solve all problems . I think the whole industry is seriously abusing SPA, But it's not right SPA Their own complaints . It's the people who choose the wrong technology to solve the current problem .
The fundamental problem is not SPA The pattern is not good , It takes a lot of skill and effort to make the right SPA. obviously , Skills and time are scarce resources , The result is that most SPA It's all bullshit .
And jQuery Compared with the times , All of these component-based OTOH The framework undoubtedly brings us a better way to produce an interactive experience . This is fundamentally related to SPA Unrelated . You can use React / Vue / etc. The problem lies in , To mix ( Interaction ) Server rendered HTML, You now need to copy tags between the server language and the front-end framework . The solution is to use the same framework on the back end and the front end , And write components only once .
I'm using TALL Stack (Tailwind,Alpine.js,Laravel and Livewire) Build an application , And my productivity is incredible . There are very few build steps required ( according to .blade.php Classes used in files , compile Tailwind To reduce the size ). I like it very much CRUD, Image upload and other operations . At first I was suspicious of , But now I like this kind of construction Web How the application works . I don't know how scalable it is , But for a simple MVP, I never asked for a better stack .
I professionally wrote a complete SPA. We use React,Apollo,GraphQL,Webpack etc. .TALL The stack is full of fresh air . I couldn't even begin to explain my joy . Just happy .
Now? , I have to write about the infinite JS Code , Conflicting dependencies , Slow build time ,React Hook state management, etc .
When I talk to my colleagues about technology , They all seem to like it JS The tangle of developers , And willing to use any new framework released . I've been trying to get good old reliability SSR. Although it is often called “ weird ”, But I prefer old-fashioned technology .
I think I prefer a better developer experience and shorter production / Time to market , Instead of spending a few days trying to build a project and find strange quirks and problems , for example “ Server free modern Web Applications ” Such a complex mess .
I use Turbolinks + Stimulus The method has been a great success . There are two common patterns , for example , Delay loading content ( It's basically having URL Attribute <div>, You can AJAX Carry out excitation loading ), And it does tend to Rails Remote links to / The server javascript Response modes and small page updates .
With most React / SPA The code base ( You may send out the whole day in a whole day ) comparison , Still very productive , It's great to be able to complete a few pages of an application in a few hours .
about 2 Years ago , For the first time I was in the new Rails The application uses Turbolinks, But shocked by the impact - In terms of no page loading and overall speed , It's like SPA.
I firmly believe that this is the solution for most use cases , Combined with right React Component or Stimulus A combination of selective uses such as , In these cases, you need more complex UI Components .
版权声明
本文为[On jdon]所创,转载请带上原文链接,感谢
边栏推荐
- The data of pandas was scrambled and the training machine and testing machine set were selected
- 一篇文章带你了解CSS 渐变知识
- 小程序入门到精通(二):了解小程序开发4个重要文件
- 教你轻松搞懂vue-codemirror的基本用法:主要实现代码编辑、验证提示、代码格式化
- git rebase的時候捅婁子了,怎麼辦?線上等……
- 一篇文章教会你使用HTML5 SVG 标签
- Windows 10 tensorflow (2) regression analysis of principles, deep learning framework (gradient descent method to solve regression parameters)
- ES6学习笔记(四):教你轻松搞懂ES6的新增语法
- Summary of common algorithms of binary tree
- Free patent download tutorial (HowNet, Espacenet)
猜你喜欢
01. SSH Remote terminal and websocket of go language
Architecture article collection
Pattern matching: The gestalt approach一种序列的文本相似度方法
From zero learning artificial intelligence, open the road of career planning!
如何玩转sortablejs-vuedraggable实现表单嵌套拖拽功能
一篇文章带你了解SVG 渐变知识
Python download module to accelerate the implementation of recording
用一个例子理解JS函数的底层处理机制
Elasticsearch数据库 | Elasticsearch-7.5.0应用搭建实战
I've been rejected by the product manager. Why don't you know
随机推荐
教你轻松搞懂vue-codemirror的基本用法:主要实现代码编辑、验证提示、代码格式化
6.3 handlerexceptionresolver exception handling (in-depth analysis of SSM and project practice)
Network security engineer Demo: the original * * is to get your computer administrator rights! 【***】
Named entity recognition in natural language processing: tanford core LP ner (1)
Azure data factory (3) integrate azure Devops to realize CI / CD
NLP model Bert: from introduction to mastery (1)
Classical dynamic programming: complete knapsack problem
6.1.2 handlermapping mapping processor (2) (in-depth analysis of SSM and project practice)
Summary of common string algorithms
用一个例子理解JS函数的底层处理机制
Music generation through deep neural network
How to demote domain controllers and later in Windows Server 2012
ES6 essence:
MeterSphere开发者手册
Face to face Manual Chapter 16: explanation and implementation of fair lock of code peasant association lock and reentrantlock
Filecoin主网上线以来Filecoin矿机扇区密封到底是什么意思
合约交易系统开发|智能合约交易平台搭建
vue任意关系组件通信与跨组件监听状态 vue-communication
仅用六种字符来完成Hello World,你能做到吗?
Word segmentation, naming subject recognition, part of speech and grammatical analysis in natural language processing