# Bad value “rocketlazyloadscript” for attribute “type” on element “script”: Subtype missing.

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-rocketlazyloadscript-for-attribute-type-on-element-script-subtype-missing
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

## Understanding the Issue

MIME types follow a specific format: a type and a subtype separated by a forward slash, such as `text/javascript` or `application/json`. When the W3C validator encounters `type="rocketlazyloadscript"` on a `<script>` element, it flags it because this value has no slash and no subtype — it doesn't conform to the MIME type syntax defined in the [HTML specification](https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type).

The value `rocketlazyloadscript` is intentionally set by the [WP Rocket](https://docs.wp-rocket.me/article/1569-w3c-validation-errors) WordPress caching and performance plugin. WP Rocket changes the `type` attribute of `<script>` elements from `text/javascript` (or removes the default) and replaces it with this custom value. This prevents the browser from executing the script immediately on page load. WP Rocket's JavaScript then swaps the `type` back to a valid value when the script should actually be loaded, achieving a lazy-loading effect that can improve page performance.

## Why This Is Flagged

The HTML specification states that if the `type` attribute is present on a `<script>` element, its value must be one of the following:

- A valid JavaScript MIME type (e.g., `text/javascript`) — indicating the script should be executed.
- The string `module` — indicating the script is a JavaScript module.
- Any other valid MIME type that is **not** a JavaScript MIME type — indicating a data block that the browser should not execute.

Since `rocketlazyloadscript` is not a valid MIME type at all (it lacks the `type/subtype` structure), it fails validation. While browsers will simply ignore scripts with unrecognized `type` values (which is exactly what WP Rocket relies on), the markup itself is technically non-conforming.

## How to Fix It

Because this value is generated by a plugin rather than authored manually, your options are:

1. **Configure WP Rocket to exclude specific scripts** — In WP Rocket's settings under "File Optimization," you can exclude individual scripts from the "Delay JavaScript execution" feature. This prevents WP Rocket from modifying their `type` attribute.

2. **Disable delayed JavaScript execution entirely** — If W3C compliance is critical, you can turn off the "Delay JavaScript execution" option in WP Rocket. This eliminates the validation errors but sacrifices the performance benefit.

3. **Accept the validation errors** — WP Rocket [acknowledges these errors](https://docs.wp-rocket.me/article/1569-w3c-validation-errors) in their documentation and considers them an expected side effect of their optimization technique. Since browsers handle the non-standard `type` gracefully (by not executing the script), there is no functional or accessibility issue. The errors are purely a standards compliance concern.

## Examples

### Invalid: Non-standard type value (generated by WP Rocket)

```html
<script type="rocketlazyloadscript" src="/js/analytics.js"></script>
```

The validator reports: **Bad value "rocketlazyloadscript" for attribute "type" on element "script": Subtype missing.**

### Valid: Standard type attribute

```html
<script type="text/javascript" src="/js/analytics.js"></script>
```

### Valid: Omitting the type attribute entirely

Since `text/javascript` is the default for `<script>` elements in HTML5, the `type` attribute can be omitted entirely:

```html
<script src="/js/analytics.js"></script>
```

### Valid: Using a module script

```html
<script type="module" src="/js/app.js"></script>
```

### Valid: Using a data block with a proper MIME type

If you need a non-executed data block, use a valid MIME type that isn't a JavaScript type:

```html
<script type="application/json" id="config">
  {"lazy": true, "threshold": 200}
</script>
```
