marko-js / marko

A declarative, HTML-based language that makes building web apps fun
https://markojs.com/
MIT License
13.28k stars 641 forks source link

[Question] What is the benefit for using client-reorder #783

Closed mauricionr closed 6 years ago

mauricionr commented 6 years ago

With markojs 4, anything change for client-reorder?

what the benefit for using client-reorder?

Thanks :smile:

mauricionr commented 6 years ago

if i have two await's in one page, the second await only will be triggered after the first one?

patrick-steele-idem commented 6 years ago

There were no changes related to client-reorder when going from Marko v3 to Marko v4.

The benefit of client-reorder can be seen in Slides: Marko ❤️ Node.js (slide 14, "out-of-order flushing" row)

if i have two await's in one page, the second await only will be triggered after the first one?

The will be triggered synchronously since there is no blocking (essentially, they will be triggered on the same tick, but won't be rendered until the associated promise resolves). Marko will take care of flushing the HTML output in the correct order.

mauricionr commented 6 years ago

@patrick-steele-idem but client-reorder affect SEO right?

the crawlers are not able to crawl the contet because they are hidden :thinking:

DylanPiercey commented 6 years ago

@mauricionr That is true, however you can detect if a crawler is accessing the site and turn off client-reorder. Another thing @mlrawlings mentioned before is disabling client-reorder until you are positive JavaScript is working by setting a cookie in the browser and detecting it server side to enable client-reorder which I think is a decent approach.

mauricionr commented 6 years ago

Thanks @DylanPiercey !

i could not understand this part

Another thing @mlrawlings mentioned before is disabling client-reorder until you are positive JavaScript is working by setting a cookie in the browser and detecting it server side to enable client-reorder

:thinking:

DylanPiercey commented 6 years ago

@mauricionr basically you add a script that does this:

document.cookie = 'use-client-reorder=1'

And then in the server check that cookie and only use the client-reorder feature if that cookie was set in the browser. (It would not work for initial render)