This will allow the use of a JS file doing everything it needs that doesn't need drupal.js or jquery to work. Meaning that for those who have the shortcut module disabled, on pages that usually don't have JS only 615b (not minified) of js will be added. Very reasonable if you ask me.
The toogle menu callback and all that needs to be move to shortcut since that's what is using it.
Here is a preview patch to remove the JS from toolbar. Activate toolbar and deactivate shortcut then enjoy the speed :)
The patch needs work but I'm putting it out there for people to follow.
Comment | File | Size | Author |
---|---|---|---|
#6 | core-simplify-toolbar-1772724-6.patch | 23.57 KB | nod_ |
#3 | core-simplify-toolbar-1772724-3.patch | 22.58 KB | nod_ |
#2 | core-simplify-toolbar-1772724-2.patch | 9.91 KB | nod_ |
core-simplify-toolbar.patch | 7.2 KB | nod_ | |
Comments
Comment #2
nod_Removed the cookie in JS. no-js cookie-based fallback still works.
Moved the shortcut-related js in shortcut.js so that toolbar.js has no dependencies at all.
Still need to move the HTML/PHP related things from toolbar to shortcut.
Comment #3
nod_Let see how much I'm breaking things.
Move the related php to the shortcut module, toolbar is now a really simple module :)
Comment #4
andypostHow it would work if no localStorage available?
Another cookie? How this affects localStorage() and JS code above?
Comment #5
nod_It's D8 so IE8+ localstorage is available in the targeted browsers (have a look at tabledrag, we're already using localStorage). If it's not available the JS'll probably crash.
It's not another cookie, it's for the noJS fallback, the cookie was already there. It just won't be used (and actually ignored) when JS is on.
Comment #6
nod_reroll, still some fishy things going on but it works.
Comment #7
nod_Got some data: This patch removes the jQuery/drupal.js dependency on the toolbar when you're not using the shortcut module.
With toolbar enabled, shortcut disabled, over 139 pages of core backend, before the patch, the average front-end loading time is
229ms
(139 pages have jQuery) After the patch it's168ms
(94 pages have jQuery). That's a Drupal backend that is rendering 25% faster on desktop. Mobile will benefit much more since the CSS/HTML time is much closer to desktop than the x10 for JS on mobile. I'm on the road and don't have my mobile testing setup.Loading time is between domLoading (HTML DOM is constructed) and domComplete (everything is loaded, images, scripts, css). This time exclude de facto all networking time (and I'm testing on localhost) this is only the time it takes to render and display CSS/HTML/JS.
Used the navigation_timing and navigation_trail module to get the data http://drupal.org/project/navigation_timing
Comment #8
Wim LeersGREAT detective work, @nod_!
Comment #9
nod_new toolbar fixes this mess :) see #1137920: Fix toolbar on small screen sizes and redesign toolbar for desktop.