Why Not Just use Javascript and NodeJS instead of these Forever Coming and Going Frameworks?

I've been using Javascript since Netscape Navigator. Over the years, I'd learn new platforms that come along. It never clicked as to why bother with them beyond JQUERY. It finally clicked for me.

Sean J. Miller

So, you learned PHP, (Classic) ASP, then ASP.NET MVC, then JQuery, then REACT, and now there is Next.js.  All of this craziness is always simply based on HTML and Javascript at the end of the day.  So, why not just use Javascript in your HTML and make a single page app back to your backend?  Using NodeJS as your server, you can your entire skillbase covered, right?

 

It finally jumped out for me.  I'm learning Next.JS and they stated the following:

Furthermore, in a production build of Next.js, whenever Link components appear in the browser’s viewport, Next.js automatically prefetches the code for the linked page in the background. By the time you click the link, the code for the destination page will already be loaded in the background, and the page transition will be near-instant!

Client-Side Navigation - Navigate Between Pages | Learn Next.js (nextjs.org)

 

There you go.  It finally is worth it.  Yes, I could simply use AJAX to do some posts from Javascript methods just like 20 years ago - the difference is that it Next.js is now prefetching every clickable thing on the page.  So, as the user dumbs their way around the page - it's loading in the background everything they might hit next - in turn providing an immediate tweak of content.

For example, let's say I have a DIV that appears collapsed with an icon to expand it.  When its expanded, it's going to show a pretty table of the 10 day weather forecast.  This could already be fetched by the time they click the icon.

At work, I had dreamed up a Field Guide concept.  Everything you ever would dream of is on one single page.  However, being written with JQuery, each click, the user has to wait for a spinning GIF while the sections are loaded.

Now sure, I could do some clever setTimeOut routine that runs to get stuff, but that gets messy.  With Next.js, every hidden div the user could twist out can be a different "page", allowing you to split the code out for easier readability.  I wish they used a different term than page, but I guess you just got to get your head around it.  They chose it because you can link just to a blurb of code or use it like it's a routed page on an old school server.

The Next.JS REACT framework is intended to provide the feel of Javascript with an easy to read directory structure of code - and brings prefetching.  In turn, this approach now makes sense to me.

-Sean

Have a question?
Back to Home