Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choosing classic Javascript Blocks or ESNEXT Blocks #4050

Closed
davidperezgar opened this issue Dec 15, 2017 · 7 comments
Closed

Choosing classic Javascript Blocks or ESNEXT Blocks #4050

davidperezgar opened this issue Dec 15, 2017 · 7 comments

Comments

@davidperezgar
Copy link
Member

Hello,
Which code do we should to use to build Gutenberg's blocks? Classic seems to be cleaner and easiest code, but I don't know which one do we have to use in order to work with code that will work in next year...

What do you recommend?

@gziolo
Copy link
Member

gziolo commented Dec 16, 2017

I assume you mean by classic ES5 JavaScript that works in every browser out of the box today. Correct me if I’m wrong. Taking into account the way JavaScript language evolves you can safely bet that ES5 will be supported for a very long time. We didn’t have any breaking changes that would make any bits of old syntax to break since I remember. General approach has changed since they introduced ES.next which has started with ES6, aka ES2015. The add new features to the language every year, but don’t modify the existing syntax. One of the drawbacks of using ES.next is that it isn’t fully supported by all browser vendors, which enforces using build step that transforms your code to ES5 to make sure it works everywhere. In the future this difference might become less prominent as all the browsers implement new JS features.

To answer your question, you can safely start with classic (ES5) today and dive into ES.next once your block is working as expected. The best part about ES.next is that it has to work with ES5 syntax, too. So migration done this way is going to be straightforward, you will have to figure out how to add build step I mentioned before. We have some examples of blocks which present how this can be done. In the future we might be offering a recommended script for builds when someone wants to use ES.next.

If you want me to elaborate more on something or I wasn’t clear enough let me know 😃

@davidperezgar
Copy link
Member Author

Hello! Thanks for your arguments... I’ve saw the code examples and the classic(I assume that is ES5) has less files and I understand better. So, I’ll use it then...
Thanks!

@gziolo
Copy link
Member

gziolo commented Dec 16, 2017

👍

@Shelob9
Copy link
Contributor

Shelob9 commented Dec 16, 2017

Related : wp-cli/scaffold-command#106

@ntwb
Copy link
Member

ntwb commented Dec 17, 2017

Also checkout the Gutenberg-Examples repo: https://github.com/WordPress/gutenberg-examples

@stgoos
Copy link

stgoos commented Oct 2, 2018

One of the drawbacks of using ES.next is that it isn’t fully supported by all browser vendors, which enforces using build step that transforms your code to ES5 to make sure it works everywhere. In the future this difference might become less prominent as all the browsers implement new JS features.

@gziolo, that only has impact when you want to write / edit a post, right? Not when a user just visits the website, or am I wrong here?

@gziolo
Copy link
Member

gziolo commented Oct 4, 2018

@gziolo, that only has impact when you want to write / edit a post, right? Not when a user just visits the website, or am I wrong here?

Nope, this applies in general to JavaScript usage in browsers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants