swc-project/swc · error · Error

BadStartTagInNoscriptInHead

BadStartTagInNoscriptInHead

Error message

Bad start tag in "{tag_name}" in "noscript" in "head"

What it means

HTML parse error in the 'in head noscript' insertion mode: a start tag that is not one of the permitted head elements (link, meta, title, script, style) appeared inside <noscript> in <head>; the tag name is captured in the error and recovery follows the anything-else rules (close noscript/head and reprocess).

Source

Thrown at crates/swc_html_parser/src/parser/mod.rs:1991

                    // Reprocess the token.
                    _ => {
                        anything_else(self, token_and_info)?;
                    }
                }
            }
            // The "in head noscript" insertion mode
            InsertionMode::InHeadNoScript => {
                let anything_else =
                    |parser: &mut Parser<I>, token_and_info: &mut TokenAndInfo| -> PResult<()> {
                        match &token_and_info.token {
                            Token::Character { .. } => {
                                parser.errors.push(Error::new(
                                    token_and_info.span,
                                    ErrorKind::NonSpaceCharacterInNoscriptInHead,
                                ));
                            }
                            Token::StartTag { tag_name, .. } => {
                                parser.errors.push(Error::new(
                                    token_and_info.span,
                                    ErrorKind::BadStartTagInNoscriptInHead(tag_name.clone()),
                                ));
                            }
                            Token::EndTag { tag_name, .. } => {
                                parser.errors.push(Error::new(
                                    token_and_info.span,
                                    ErrorKind::StrayEndTag(tag_name.clone()),
                                ));
                            }
                            Token::Eof => {
                                parser.errors.push(Error::new(
                                    token_and_info.span,
                                    ErrorKind::EofWithUnclosedElements,
                                ));
                            }
                            _ => {
                                unreachable!()

View on GitHub (pinned to 5176682b65)

Solutions

  1. Move the element out of <head><noscript> into <body>
  2. Keep only allowed head elements (link/meta/title/script/style) inside noscript in head
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/swc_html_parser/src/parser/mod.rs:1991 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17). Data as JSON: /api/errors/b910ddec1645c3a8. Report an issue: GitHub.