Javascript Required Messages
When Javascript is disabled, Site Kit pages are blank and do not load. While WordPress' functionality is severely limited if Javascript is disabled, it would be good to at least display a message in a <noscript> tag when loading SiteKit pages that Javascript is required to use Site Kit.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- When JavaScript is disabled in the browser, accessing any Site Kit admin screen (dashboard, module screens, settings), as well as the admin bar menu, should display a user-facing message: "The Site Kit by Google plugin requires JavaScript to be enabled in your browser."
Implementation Brief
- Create a
Requires_Javascripttrait in theCore/Utilnamespace which provides aget_noscript_htmlmethod to return the<noscript>html as a string. This way we have a single source for all places we need to include the tag. - Add the
<noscript>tag to the Screenrender()method https://github.com/google/site-kit-wp/blob/b42304c5e577eb13fa5934bd9c02f2a0cba1e44b/includes/Core/Admin/Screen.php#L204-L210 which callsrender_callback()from each screen to ensure the tag is included for all Site Kit screens. The tag should only be rendered if there is arender_callback - Add
<noscript>tag to the admin bar inAdmin_Bar::menu_markup() - Add
<noscript>tag to the activation banner inActivation::get_activation_notice - Add CSS to hide all Site Kit loading bars (and/or app render targets) if JS is not enabled using the
body.no-jsclass- Ideally something like
body.no-js #js-googlesitekit-*
- Ideally something like
QA Brief
Affected areas
- Site Kit plugin activation notice
- Site Kit WordPress dashboard widget
- Site Kit splash (setup) pages
- Site Kit module dashboard pages
- Site Kit main dashboard page
- Site Kit settings page
- Admin Bar (post edit & post on front) for posts that have data in Search Console &/or Analytics
Expected Notice when JS is disabled
The Site Kit by Google plugin requires JavaScript to be enabled in your browser.
Steps
- Set up Site Kit as normal with JavaScript enabled
- Ensure each affected area does not display the above notice that JavaScript is required
- Disable JavaScript
- Ensure each affected area does display the above notice that JavaScript is required
Changelog entry
- Add user-facing warnings to Site Kit areas when JavaScript is disabled.
@lucymtc
Add
<noscript>with message to the Screens.php admin_head existing action
This should be in a head action, it needs to be where the actual content markup is generated.
Also, the implementation brief doesn't cover the admin bar menu.
@felixarntz for the admin pages it is specified to hook into admin_head
I have added implementation for admin bar.
@lucymtc Apologies, I originally wrote exactly the opposite of what I meant:
This ~~should~~ shouldn't be in a
headaction
<noscript> tags with the fallback messages should be rendered with the markup exactly where they should appear, for example in the render_callback() methods for the screen, or the Admin_Bar::menu_markup() method.
Implementation brief updated
Create helper in
includes/Core/Util/to return the<noscript>tag so we have a single source for any different places we need to include the tag.
Just to clarify, I think this should be implemented as a trait with a protected method, as it's quite specific (the Core/Util namespace is fine). We don't need an own class or public function for that. Other than that the IB looks solid.
It's worth noting that Puppeteer has page.setJavaScriptEnabled( false ) so we should be able to write a straightforward E2E test for this one to ensure the right <noscript> content is being loaded.
@felixarntz I updated the IB to include the Activation notice/app since this hadn't changed since July. I also added a point to use CSS to hide loading bars, etc using core's no-js class that wp-admin provides. Everything else is the same so I don't think this warrants a full re-review, but please take a look and let us know if there's anything else needed here 👍
Tested
Disabled Javascript:

Confirmed the message is displayed:

Passed QA ✅
Tested
Site Kit plugin activation notice

Site Kit WordPress dashboard widget

Site Kit splash (setup) pages

Site Kit module dashboard pages

Site Kit main dashboard page - Pass Above
Site Kit settings page

Admin Bar (post edit & post on front) for posts that have data in Search Console &/or Analytics

Thanks for the follow up screenshots @cole10up. I think they may be out of order or missing a few though.
To clarify a few things:
-
The setup/splash page is where you land if you click Site Kit > Dashboard in the admin menu but it hasn't been set up yet. This one (you labelled as "Activation notice")

- The activation notice is what shows up immediately after activating the plugin on
plugins.php
- The activation notice is what shows up immediately after activating the plugin on
-
Site Kit splash (setup) pages

- This is totally out of our hands as it's an
accounts.google.comURL.
- This is totally out of our hands as it's an
-
Admin Bar (post edit & post on front) for posts that have data in Search Console &/or Analytics
- Your screenshot here doesn't show that the Site Kit admin bar menu item is there. You'll need to use the developer settings plugin and match the page/post URL to one that has data on the site that you're using in the Custom Site URL. It should essentially look the same as this one from the front-end though:

- Your screenshot here doesn't show that the Site Kit admin bar menu item is there. You'll need to use the developer settings plugin and match the page/post URL to one that has data on the site that you're using in the Custom Site URL. It should essentially look the same as this one from the front-end though:
-
Site Kit WordPress dashboard widget
- This screenshot isn't showing the WordPress dashboard 😄 (
/wp-admin/index.php)
- This screenshot isn't showing the WordPress dashboard 😄 (
Verified this message appears on the main dashboard, single page stats, settings page.