Skip to content

Commit

Permalink
refactor: call no-js removal earlier
Browse files Browse the repository at this point in the history
- Moves the `no-js` class to the `html` element.
- Remove the class early with a inlined script tag in the head.
- Adds `js` class
- Use `@wordpress/dom-ready` in editor script.
- Remove our `domReady` utility.
  • Loading branch information
knowler committed Dec 29, 2021
1 parent f1adf08 commit 5b7326c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 27 deletions.
8 changes: 6 additions & 2 deletions index.php
@@ -1,12 +1,16 @@
<!doctype html>
<html <?php language_attributes(); ?>>
<html <?php language_attributes(); ?> class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="module">
document.documentElement.classList.remove('no-js');
document.documentElement.classList.add('js');
</script>
<?php wp_head(); ?>
</head>

<body <?php body_class('no-js'); ?>>
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
<?php do_action('get_header'); ?>

Expand Down
11 changes: 0 additions & 11 deletions resources/scripts/app.js
@@ -1,14 +1,3 @@
import {domReady} from '@scripts/components';

/**
* Remove `.no-js` from document body
* when DOM has loaded.
*/
domReady(() => {
document.body.classList.contains('no-js') &&
document.body.classList.remove('no-js');
});

/**
* Accept module updates
*
Expand Down
12 changes: 0 additions & 12 deletions resources/scripts/components/index.js

This file was deleted.

3 changes: 1 addition & 2 deletions resources/scripts/editor.js
@@ -1,7 +1,6 @@
import '@wordpress/edit-post';
import {registerBlockStyle, unregisterBlockStyle} from '@wordpress/blocks';

import {domReady} from '@scripts/components';
import domReady from '@wordpress/dom-ready';

/**
* Customize block styles
Expand Down

0 comments on commit 5b7326c

Please sign in to comment.