当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- If PPT is drawn like this, can the defense of work report be passed?
- Network security engineer Demo: the original * * is to get your computer administrator rights! 【***】
- Basic principle and application of iptables
- 6.4 viewresolver view parser (in-depth analysis of SSM and project practice)
- Python基础变量类型——List浅析
- How to encapsulate distributed locks more elegantly
- Keyboard entry lottery random draw
- I think it is necessary to write a general idempotent component
- How to use parameters in ES6
- Do not understand UML class diagram? Take a look at this edition of rural love class diagram, a learn!
猜你喜欢
Summary of common algorithms of linked list
Wow, elasticsearch multi field weight sorting can play like this
前端基础牢记的一些操作-Github仓库管理
Free patent download tutorial (HowNet, Espacenet)
2019年的一个小目标,成为csdn的博客专家,纪念一下
Mongodb (from 0 to 1), 11 days mongodb primary to intermediate advanced secret
理解格式化原理
Network security engineer Demo: the original * * is to get your computer administrator rights! 【***】
Python Jieba segmentation (stuttering segmentation), extracting words, loading words, modifying word frequency, defining thesaurus
Architecture article collection
随机推荐
快速排序为什么这么快?
Python + appium automatic operation wechat is enough
Interpretation of Cocos creator source code: engine start and main loop
What is the difference between data scientists and machine learning engineers? - kdnuggets
有了这个神器,快速告别垃圾短信邮件
Python Jieba segmentation (stuttering segmentation), extracting words, loading words, modifying word frequency, defining thesaurus
Character string and memory operation function in C language
Relationship between business policies, business rules, business processes and business master data - modern analysis
use Asponse.Words Working with word templates
Classical dynamic programming: complete knapsack problem
一篇文章教会你使用Python网络爬虫下载酷狗音乐
Keyboard entry lottery random draw
前端工程师需要懂的前端面试题(c s s方面)总结(二)
Custom function form of pychar shortcut key
Jetcache buried some of the operation, you can't accept it
After reading this article, I understand a lot of webpack scaffolding
How to become a data scientist? - kdnuggets
Python saves the list data
Pollard's Rho algorithm
[JMeter] two ways to realize interface Association: regular representation extractor and JSON extractor