Skip to content

Commit 16c35f1

Browse files
authored
Add type="module" to isAsync for no-blocking-script (#97)
1 parent 6c51c88 commit 16c35f1

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

rules/no-blocking-script/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
## true
66
Скрипты должны быть подключены в самом низу страницы, чтобы при её загрузке не блокировать отображение содержимого.
77

8-
Если скрипт не блокирующий (`defer`, `async`), то можно в `<head>`
8+
Если скрипт не блокирующий (`defer`, `async` или `type="module"`), то можно в `<head>`.
99

1010
Проблемными считаются следующие шаблоны:
1111
```html
@@ -37,3 +37,11 @@
3737
</html>
3838
```
3939

40+
```html
41+
<html lang="ru">
42+
<head>
43+
<script src="app.js" type="module"></script>
44+
</head>
45+
<body>…</body>
46+
</html>
47+
```

rules/no-blocking-script/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22
// eslint-disable-next-line camelcase
3-
const { is_tag_node, has_attribute } = require('@linthtml/dom-utils');
4-
const isAsync = (node) => has_attribute(node, 'async') || has_attribute(node, 'defer');
3+
const { attribute_has_value, is_tag_node, has_attribute } = require('@linthtml/dom-utils');
4+
const isAsync = (node) => has_attribute(node, 'async') || has_attribute(node, 'defer') || attribute_has_value(node, 'type', 'module');
55
const isLastBodyElement = (node) => {
66
if (node.parent.name !== 'body') {
77
return false;

0 commit comments

Comments
 (0)