swc-project/swc · error · Error

NonSpaceCharacterInNoscriptInHead

NonSpaceCharacterInNoscriptInHead

Error message

Non-space character inside "noscript" inside "head"

What it means

HTML parse error in the 'in head noscript' insertion mode (with scripting enabled): a character token that is not whitespace was encountered while only whitespace, comments and a few head elements are allowed; recorded on parser.errors and the token is otherwise handled by the anything-else recovery path.

Source

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

                    //
                    // Pop the current node (which will be the head element) off the stack of open
                    // elements.
                    //
                    // Switch the insertion mode to "after head".
                    //
                    // 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(

View on GitHub (pinned to 5176682b65)

Solutions

  1. Move non-whitespace content out of <noscript> in <head> into the body
  2. Restructure the document so <noscript> only appears where flow content is permitted
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/swc_html_parser/src/parser/mod.rs:1985 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/4d75df33dcf4f364. Report an issue: GitHub.