Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1388106
    Lucci
    Participant

    Curious 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?

    #1388386
    Rupok
    Member

    Hi there,

    If it’s your custom CSS and the browser support that, you can still use ES6 syntax.

    Thanks!

    #1388783
    Lucci
    Participant

    my 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)

    #1388897
    Thai
    Moderator

    Hi There,

    Please try with this code:

    var balls="hello"; console.log(balls);

    Let us know how it goes!

    #1389095
    Lucci
    Participant

    yes 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.

    #1389692
    Rupok
    Member

    Hi 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!

    #1391800
    Lucci
    Participant

    gotcha, thanks for the information! I did notice that the JS editor within cornerstone builder minifies the code, so that definitely makes sense.

    #1391814
    Joao
    Moderator

    Let us know if you need further assistance

    Cheers

  • <script> jQuery(function($){ $("#no-reply-1388106 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>