Default scripts without jQuery dependency in Sage 9

I love that there’s less dependence on jQuery when it’s not needed. Wouldn’t it make sense to get rid of the other dependencies?

Suggestion 1:

/** Load Events
 *  jQuery example for reference

// jQuery(document).ready(() => routes.loadEvents());

var callback = () => routes.loadEvents();

if (
    document.readyState === "complete" ||
    (document.readyState !== "loading" && !document.documentElement.doScroll)
) {
} else {
  document.addEventListener("DOMContentLoaded", callback);

Suggestion 2:

wp.customize('blogname', (value) => {
    value.bind(to => querySelector('.brand').text(to));

I think we talked about this internally recently. I kind of forget where we ended up on it.

I’m personally in favour of it assuming we can easily support the same browsers that the jQuery code does.

That being said, I assume almost every WP site is going to use jQuery anyway.


Out of all the scripts file in the /scripts/ folder, I can’t see any reason not to completely use ES6 anymore unless Sage is supporting older than IE8 for document.querySelector() or $(document).ready(). Arrow functions, which aren’t supported in any IE browser, are already included in several of the script files.

This also sets up the scripts folder to be progressive when ES6 and beyond are more common in plugins and themes.