How an Unclosed HTML Tag Broke Drupal JavaScript on a Single Page

In a detailed debugging story, Mike Herchel recounts how Drupal’s JavaScript broke during a live demo—on a single theme settings page. Console errors pointed to missing drupalSettings values, yet the relevant JSON script existed in the HTML source. After disabling BigPipe and removing injected scripts, Mike traced the problem to the drupalSettingsLoader.js file, which failed to locate the expected <script> tag in the DOM. This ruled out core failure and pointed to a structural issue with the markup.

Closer inspection revealed the drupalSettings script was wrapped inside an <em> element in the DOM—though this tag didn’t exist in the source HTML. The browser had restructured the DOM due to an unclosed <em> tag elsewhere in the markup, breaking the JavaScript loader’s selector that requires the script to be a direct child of <body>.

Once the rogue tag was closed, all functionality returned instantly. This case illustrates how subtle markup issues can undermine major frontend systems, and highlights the value of understanding the DOM and using browser developer tools for precise debugging.

Disclosure: This content is produced with the assistance of AI.

Disclaimer: The opinions expressed in this story do not necessarily represent that of TheDropTimes. We regularly share third-party blog posts that feature Drupal in good faith. TDT recommends Reader's discretion while consuming such content, as the veracity/authenticity of the story depends on the blogger and their motives. 

Note: The vision of this web portal is to help promote news and stories around the Drupal community and promote and celebrate the people and organizations in the community. We strive to create and distribute our content based on these content policy. If you see any omission/variation on this please reach out to us at #thedroptimes channel on Drupal Slack and we will try to address the issue as best we can.

Related Organizations

Related People

Upcoming Events

Latest Opportunities