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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, core-simplify-toolbar.patch, failed testing.

nod_’s picture

Status: Needs work » Needs review
FileSize
9.91 KB

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.

nod_’s picture

Let see how much I'm breaking things.

Move the related php to the shortcut module, toolbar is now a really simple module :)

andypost’s picture

+++ b/core/modules/shortcut/shortcut.jsundefined
@@ -0,0 +1,112 @@
+var collapseShortcut = JSON.parse(localStorage.getItem('Drupal.shortcut.collapsed'));

How it would work if no localStorage available?

+++ b/core/modules/shortcut/shortcut.moduleundefined
@@ -207,6 +219,31 @@ function shortcut_block_view($delta = '') {
+  setcookie('Drupal.shortcut.collapsed', !_shortcut_is_collapsed(), NULL, $base_path);

Another cookie? How this affects localStorage() and JS code above?

nod_’s picture

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.

nod_’s picture

reroll, still some fishy things going on but it works.

nod_’s picture

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's 168ms (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

Wim Leers’s picture

GREAT detective work, @nod_!

nod_’s picture

Status: Needs review » Closed (duplicate)