- jQuery takes a long time to load and execute on mobile, not having that would greatly help front-end performance (we're talking about at least 200ms on mobile).
- It is not possible to use Drupal without jQuery. The only way to do that is rewrite all core JS you're using.
- A few wrappers for DOM manipulations and AJAX calls will be introduced for ease of development.
- This is not about NIH. Small and specialized third party libraries will be used when necessary. Events are a good example of something we won't be doing all over again.
- Depending on how things goes, wrapper functions could be considered private for core use only. We're talking about something like 10-20 helper functions to make the DOM more friendly. Contrib should not assume anything is provided by core at this level.
- querySelector and querySelectorAll are faster than sizzle. Yes there are quirks to it but nothing impossible to manage.
- Contrib will be able to use the latest and bestest jQuery/UI version at all times (See notes below).
- This will help people used to other libraries get into Drupal.
- Hopefully this will attract non-drupal JS developers that we need.
- This is about making Drupal "fast by default", not about making contrib life harder.
You're probably thinking that now every single module will have to depend on jquery_update/jquery module. Since it is not in core anymore, don't forget that jQuery can be added with info files at the theme or module level.
Since so much of contrib relies on jQuery, it's possible to add a
drupal_add_jquery function, pointing to google CDN or another more appropriate CDN. As long as the actual jQuery source code is not in core and that core code does not depend on jQuery. That means contrib will simply need to call this function to get jQuery on the page. This would be a bit similar to the current jQuery UI situation: provided by core but not used by core.
Also loading from a CDN mean it's likely that the file is already in the browser's cache.
I'd like to say it clearly, I'm not against jQuery as a library. I actually like it very much, that's the point! I'm against the fact that it's required in Drupal and that it means we're stuck with an outdated version. Newer jQuery version have performance improvement and nice API additions.
Changes for Contrib
- If we introduce a
- If we don't have this function in core, your module will have to add the "jquery" module as a dependency. This "jquery" module will provide the jQuery library for you to use.
- In both situation you will be able to use the latest jQuery version and core will work. Core will not break because of a jQuery API change like it's the case right now.
- It will make you add a either 1 line of PHP or 1 dependency.
There have are a few things planned once(or something alike) is in:
Basically this is about removing the need for jQuery on high-profile JS files so that it won't get loaded all the time if it's not needed.