News for hackers. Stuff that matters.
Re:A static website with React by ggregoire on Friday February 17, 2017 @10:55AM (#13669056)
> "The one that allows you to improve the quality of your code with unit testing and type checking"

Wait, are we really talking about a static website?

I'm a big fan of React and all the JS ecosystem, but when I need a static website, I just make my bunch of html files (and I copy/paste the same header/footer on each), my css file, eventually 2 lines of JS directly in a <script> tag to toggle a menu on mobile devices, I upload it on S3/CloudFront and that's it.

Re:A static website with React by kennu on Friday February 17, 2017 @11:37AM (#13669521)
I think we are taking about websites that can be hosted on a static file server like Amazon S3/CloudFront, but which also have all the dynamic features of React available for building a rich and complex UX. For instance, when working with Phenomic (which uses Webpack), it's very easy to add any necessary React components to your project simply with npm install / yarn add. So it's really a marriage of Markdown based content publishing and interactive client-side UX.
Re:A static website with React by paulddraper on Friday February 17, 2017 @03:49PM (#13671594)
I eternally have this misunderstanding. I think static means unchanging.

In this context, it means static HTTP responses, but dynamic HTML/DOM.

I want a word to mean really static.

Re:A static website with React by bloodyowl on Friday February 17, 2017 @05:29PM (#13672278)
Hello,

I'm in the core Phenomic team.

The idea in Phenomic is that we generate for each page:

- the HTML entry point, rendered like it would be with ReactDOMServer - the data-requirements of the page

That lets us offer the following: - Any page is accessible directly, without runtime (which has advantages regarding performance and SEO) - Navigation works even if JS is disabled - If JavaScript is enabled, the runtime just loads the minimum required data for the next page to display and renders it

Phenomic really is static, it just uses a few techniques that we learnt from the modern front-end development workflows and capabilities :)

Re:A static website with React by paulddraper on Friday February 17, 2017 @06:38PM (#13672657)
Neat. Thanks for the info!
Re:A static website with React by cies on Friday February 17, 2017 @04:33PM (#13671877)
In this context some HTTP responses are static. The static part of the website.

But the React app can also start consuming all kinds of webservice.

This way (1) a large part of content can be served as prerendered static HTTP responses (HTML, CSS, JS). (2) Static content not initially loaded can be served as JSON (as seen in the presentation). And (3) dynamic content (e.g. real time comments or a chat) can be non-static (one or more webservices, possibly on WebSocket thereby going beyond HTTP).

I think this may be very interesting when "big mostly static content", "need for modern web tech" and "big traffic" meet.

Re:A static website with React by kmonsen on Friday February 17, 2017 @12:03PM (#13669772)
Yes, the word static is a bit overloaded here.
Re:A static website with React by gkya on Friday February 17, 2017 @03:09PM (#13671286)
Misused, rather. This is dynamic pages, client side.
Re:A static website with React by vmarsy on Friday February 17, 2017 @11:37AM (#13669522)
I think the whole benefit of a static website generator in general is to avoid the "I copy/paste the same header/footer on each" step, especially copy-pasting the menu/header, as your menu can change as you add new pages / blog posts.

I can see good benefits of having a way to do static site generation with the React ecosystem if you're already familiar with it.

Re:A static website with React by romaniv on Friday February 17, 2017 @11:50AM (#13669641)
> I think the whole benefit of a static website generator in general is to avoid the "I copy/paste the same header/footer on each" step, especially copy-pasting the menu/header, as your menu can change as you add new pages / blog posts.

If the website is simple, you could use iframes for headers and footers.

Re:A static website with React by tokenizerrr on Friday February 17, 2017 @11:53AM (#13669687)
Except that iframes introduce additional http requests, difficulties with selecting text and all the other annoyances that come with them.
Re:A static website with React by tonyedgecombe on Friday February 17, 2017 @02:08PM (#13670821)
I'm surprised html doesn't have an include tag.
Re:A static website with React by amk_ on Friday February 17, 2017 @02:28PM (#13670963)
https://en.wikipedia.org/wiki/Server_Side_Includes

    <!--#include virtual="../snippet.html" -->
Most servers that you would get for a shared host (ie Apache, NGINX) support this.
Re:A static website with React by mikewhy on Friday February 17, 2017 @02:56PM (#13671178)
Whoa. Flashbacks to SHTML.
Re:A static website with React by gambler on Friday February 17, 2017 @07:06PM (#13672816)
I'm annoyed but not surprised. This is how a lot of HTML was developed.

First, you have a need. Then you get a crippled native "solution", that emerges from some committee and therefore doesn't really solve anything. In lieu of alternatives, a lot of people use it anyway. Then the problem is ignored long enough so other people come up with hacks to solve the same problem slightly less bad. Then the problem is ignored semi-permanently because 'hey, you can just use one of those hacks!'. (Look up iframe seamless attribute.)

Re:A static website with React by ravitation on Friday February 17, 2017 @12:49PM (#13670189)
> I just make my bunch of html files (and I copy/paste the same header/footer on each), my css file, eventually 2 lines of JS directly in a <script> tag to toggle a menu on mobile devices

The workflow and output remains largely unchanged, but something like Jekyll would probably make the resulting codebase a little cleaner.

Otherwise, I completely agree. There are better tools for building static sites.

Re:A static website with React by tomatsu on Friday February 17, 2017 @01:16PM (#13670395)
> I copy/paste the same header/footer on each

You could at least use server side includes (SSI) to include those snippets.

Static website generators like Jekyll are pretty cool, though. You should definitely check them out.

Re:A static website with React by sebringj on Friday February 17, 2017 @12:58PM (#13670247)
I think you're missing the point. You can use all the UI treatments and components, using AJAX if you want to. It basically gives you a lot of options and you're not stuck using jQuery plugins ad hoc when you want to make a customer form or list your latest products with search functionality on a site that is mostly static.
Re:A static website with React by alfonsodev on Friday February 17, 2017 @11:37AM (#13669517)
I think the web got complicated when somebody though about users creating content that other user could see. It could have been done with a mailto tag! instead of creating php! :p
Re:A static website with React by EGreg on Friday February 17, 2017 @01:58PM (#13670742)
And then install mail client plugins that transform all that information and solve mental poker for N participants! Yes!
Re:A static website with React by 91bananas on Friday February 17, 2017 @11:52AM (#13669662)
Yes, I always hear people raving about how awesome their email client's UX is /s
Re:A static website with React by stevekemp on Friday February 17, 2017 @01:56PM (#13670724)
That'd be me; my email-client has Conway's game of life built in ;)
Re:A static website with React by yeahbutbut on Friday February 17, 2017 @03:05PM (#13671254)
Found the emacs user! ;-)
Re:A static website with React by stevekemp on Friday February 17, 2017 @10:15PM (#13673406)
Close, but no cigar! I wrote my own mail client, inspired by Mutt but extended with a real programming language (lua):

https://lumail.org/

I added a game of life mostly to prove the extensibility covered the screen modes.

Re:A static website with React by ulucs on Saturday February 18, 2017 @08:10AM (#13674688)
Same, but I'm exceptionally lazy so I use SSI to include the footer/header to avoid having to copy/paste code
Re:A static website with React by miguelrochefort on Friday February 17, 2017 @12:49PM (#13670185)
> I just make my bunch of html files (and I copy/paste the same header/footer on each), my css file, eventually 2 lines of JS directly in a <script> tag to toggle a menu on mobile devices, I upload it on S3/CloudFront and that's it.

You copy/paste code? This is crazy.

Re:A static website with React by learc83 on Friday February 17, 2017 @01:07PM (#13670329)
There are often of situations where the long term benefits of automating something isn't worth the up front cost.

Throwing together a small static website with a few pages, in my experience, is one of those situations.

Re:A static website with React by wazanator on Friday February 17, 2017 @01:37PM (#13670568)
But the up front cost of using something like Jekyll is about fifteen minutes of work. Plus you can find a lot of free templates online that make your basic site not look awful.
Re:A static website with React by Touche on Friday February 17, 2017 @01:49PM (#13670658)
I know I've spent hours trying to get Ruby setup and figuring our why bundler install failed, so disagree with your "fifteen minutes" comment. Maybe in the best case scenario.