Skip to content

fix(browser): drop the dead --disable-javascript switch from text_mode - #2291

Open
talelboussetta wants to merge 2 commits into
unclecode:developfrom
talelboussetta:bugfix/text-mode-dead-js-flag
Open

talelboussetta wants to merge 2 commits into
unclecode:developfrom
talelboussetta:bugfix/text-mode-dead-js-flag

Conversation

@talelboussetta

@talelboussetta talelboussetta commented Sep 25, 2026 •

Copy link
Copy Markdown

Summary

text_mode appends --disable-javascript to Chromium's flags (both flag builders in browser_manager.py). Chromium has no such switch and ignores it, so text_mode has never disabled scripting: inline and external scripts run with it exactly as without it. The entry only suggests otherwise to anyone reading the flag list. JavaScript is turned off with BrowserConfig(java_script_enabled=False), which sets it on the browser context.

This removes the entry and says in the text_mode docs that JavaScript still runs. No behaviour change.

Left as is: the 0.4.1 release note says text_mode "blocks image and JavaScript resources"; it's a historical post. text_mode's route blocking covers images, fonts, media, documents and archives, not .js. deploy/docker/c4ai-code-context.md still lists the switch too; it's a generated snapshot (2025-04-21) that already predates 0.9.4's changes to the same file, so it's left for its next regeneration.

List of files changed and why

  • crawl4ai/browser_manager.py: drop --disable-javascript from ManagedBrowser.build_browser_flags() and BrowserManager._build_browser_args().
  • crawl4ai/async_configs.py, docs/md_v2/core/browser-crawler-config.md: one line saying JavaScript still runs under text_mode, and what turns it off.
  • tests/unit/test_text_mode_flags.py (new): the switch is absent from both builders, and the switches that do take effect stay.

How Has This Been Tested?

pytest tests/unit/test_text_mode_flags.py tests/unit/test_browser_disable_features.py
5 passed        (the dead-switch test fails on develop)

The offline suites (deploy/docker/tests without the live-server test_1–test_7 scripts, tests/unit, the pool tests) show no new failures against develop.

That the switch does nothing, on an image built from develop @ 1f68e5b, which still passes it: /crawl of a page on a local test site, so CRAWL4AI_ALLOW_INTERNAL_URLS=true, whose inline and external scripts each replace a heading. The values are the headings' text in the returned HTML.

[textmode] text_mode=True             HTTP 200: #inline='INLINE-JS-RAN' #ext='EXTERNAL-JS-RAN'
[textmode] java_script_enabled=False  HTTP 200: #inline='NOJS-INLINE' #ext='NOJS-EXTERNAL'

cc @ntohidi

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added/updated unit tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Chromium has no --disable-javascript switch and ignores it, so text_mode never
disabled scripting: inline and external scripts run with it exactly as without
it. The entry only suggested otherwise to anyone reading the flag list.
JavaScript is turned off with BrowserConfig(java_script_enabled=False), which
sets it on the browser context.

Remove it from both flag builders and say in the text_mode docs that
JavaScript still runs. No behaviour change.
Copilot AI lite review requested due to automatic review settings September 25, 2026 10:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Update or regenerate the Docker code-context artifact before approval.

Review effort: Lite
Findings: None

What changed in this PR

Removes the ineffective JavaScript-disabling flag from text_mode and clarifies its behavior.

Changes:

  • Removes the flag from both browser argument builders.
  • Updates configuration documentation.
  • Adds regression tests.
File Summary
tests/​unit/​test_text_mode_flags.py Tests flag construction.
docs/​md_v2/​core/​browser-crawler-config.md Clarifies JavaScript behavior.
crawl4ai/​browser_manager.py Removes the dead flag; Docker’s code-context artifact still needs updating.
crawl4ai/​async_configs.py Documents text_mode JavaScript behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

complete-sdk-reference.md carries the same text_mode entry as
docs/md_v2/core/browser-crawler-config.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants