Tagged: x
-
AuthorPosts
-
February 27, 2017 at 6:49 pm #1388106
LucciParticipantCurious if this is a wordpress issue or something that is implemented on the theme level (presuming it still has to be compiled down into ES5 for browser compatibility).
Anyway, it would be nice if we could use ES6 syntax within cornerstone and other javascript areas of the theme. Is this on the road map for you guys at all?
February 28, 2017 at 1:43 am #1388386
RupokMemberHi there,
If it’s your custom CSS and the browser support that, you can still use ES6 syntax.
Thanks!
February 28, 2017 at 8:25 am #1388783
LucciParticipantmy browser does support ES6 syntax for javascript. I am only interested in some minor features of it (for example using “const” to declare variables). When I try to use a simple example within the custom javascript area of the cornerstone builder, it adds an extra semi-colon causing a syntax error.
What is inputted:
const balls = “hello”;
console.log(balls);What is outputted to the page:
const;balls=”hello”;console.log(balls)February 28, 2017 at 9:36 am #1388897
ThaiModeratorHi There,
Please try with this code:
var balls="hello"; console.log(balls);Let us know how it goes!
February 28, 2017 at 12:12 pm #1389095
LucciParticipantyes var works, but I am specifically referencing ES6 syntax which allows for multiple variable types (const, let and var)
Resource: http://www.2ality.com/2015/02/es6-scoping.html
Since ES6 is becoming more popular now, I want to start getting into the habit of using the new syntax when writing my javascript. I know that in the past compilers like Babel were used to allow devs to write javascript in ES6 format and it would convert it to the standard ES5 but now that most modern browsers seem to support ES6 it would be nice to start using the new syntax (along with arrow functions) right within cornerstone and wordpress.
February 28, 2017 at 10:12 pm #1389692
RupokMemberHi there,
Thanks for writing back. You can actually use them but need to use within Child Theme by enqueuing a JavaScript file. It’s because some syntax might get deformatted on the custom JS section. Hopefully it will be properly supported on X 5.
Cheers!
March 2, 2017 at 7:43 am #1391800
LucciParticipantgotcha, thanks for the information! I did notice that the JS editor within cornerstone builder minifies the code, so that definitely makes sense.
March 2, 2017 at 7:53 am #1391814
JoaoModeratorLet us know if you need further assistance
Cheers
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1388106 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
