Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
From #784626-176: Default all JS to the footer, allow asset libraries to force their JS to the header:
+++ b/core/core.libraries.yml @@ -43,11 +43,14 @@ domready: + header: true
Let's take the drupal and dropbutton hunks out of the patch and open a follow-up to discuss.
This is that follow-up issue.
Comment | File | Size | Author |
---|---|---|---|
#13 | views-admin-nojs.png | 42.25 KB | Manuel Garcia |
Comments
Comment #1
attiks CreditAttribution: attiks commentedPost my comment here and not in #784626: Default all JS to the footer, allow asset libraries to force their JS to the header
#177Does this also means it will be outputted on every request?
document.documentElement.className += ' js';
only has to be in the head if a theme uses the js class, any idea if a lot of themes are doing it?Comment #2
Wim Leerscatch and I discussed the merits of the
.js
class being set on the<html>
tag bycore/drupal
(drupal.js
).So I pinged Jesse Beach, who helped finalize the dropbutton in its current implementation, to ask about its reliance on the
.js
class in its selectors. Turns out there's likely no good reason for its reliance on the.js
class, it's probably only there due to its Views legacy: https://twitter.com/wimleers/status/558614234851196928Comment #3
Wim LeersWell, any Drupal 8 theme that relies on this will be broken for anonymous users anyway then, since no JS is loaded for anonymous users by default. Themes could opt in to this by having their main global styling asset library declare a dependency on
core/drupal
.In other words: I think this is a non-issue :)
Comment #4
attiks CreditAttribution: attiks commented#3 I just saw your tweet, good to know
Comment #5
attiks CreditAttribution: attiks commentedWhat about html5shiv, looks like it gets attached by Drupal\Core\Render\Elelemt\Html?
Comment #6
Wim LeersYes,
html5shiv
is loaded on all pages. But it's wrapped in browser comments, which means it's only executed for IE <=8. So, effectively, for 99% of browsers, no JS is loaded for anonymous users.Comment #7
attiks CreditAttribution: attiks commentedComment #8
attiks CreditAttribution: attiks commented#6Thanks, maybe we should add a comment saying so, because it was not really clear to me.
Comment #9
Wim Leers#8: where do you want me to add that comment? :)
Comment #10
attiks CreditAttribution: attiks commented#9Good question, I guess in the HTML class?
Comment #11
Wim Leers#10: why does that need to be documented additionally? Anybody looking at the output sees this, and if you look at the corresponding library definition in
core.libraries.yml
, it's also clear. I don't see what we gain by also commenting on\Drupal\Core\Render\Element\Html
? Feel free to propose a patch though, but it feels like that belongs in #2409083: Remove html5shiv from being loaded, it's definitely off-topic in this issue.Comment #12
attiks CreditAttribution: attiks commented##1 You're right, way off topic and I should have looked at libraries.yml as well
Comment #13
Manuel Garcia CreditAttribution: Manuel Garcia commentedI can't think of a reason why we'd want to put dropbutton on the header.
I'll take as an example the views administration page, which has quite a few:
The page is perfectly functional for the little time the user would see the page without dropbutton being executed:
Also, once dropbutton's js has been downloaded once and the browser has it cached, the impact of having this on the bottom of the page is absolutely minimal, and barely perceivable by the human eye.
Comment #14
Wim Leers#784626: Default all JS to the footer, allow asset libraries to force their JS to the header landed, now it's time to work on this one. :)
Comment #15
Manuel Garcia CreditAttribution: Manuel Garcia commentedI think we should get rid of the .js CSS class, core should not be triggering CSSOM & layout invalidation on every page load by default. If we currently depend on this for something, let me know because I'm sure we can find a better way to deal with it.
For themes that for some reason need that class, they can add it themselves, it's a trivial thing to do.
Comment #16
catchOpened #2413847: Remove .js class from core.
Comment #17
Manuel Garcia CreditAttribution: Manuel Garcia commentedThere is one thing we did not think about, and that is that modernizr adds a
js
class, and ano-touch
class to the<html>
element as well... :\Comment #18
Fabianx CreditAttribution: Fabianx commentedWe could execute this small JS snippet for JS class as inline JS ... /me ducks, hides and runs ...
Comment #19
Wim Leers#2349591: Dropdown action list shows up as a simple list without JavaScript should help with making the Dropbutton work well at all times.
Comment #28
nod_