fix(browser): drop the dead --disable-javascript switch from text_mode - #2291
Open
talelboussetta wants to merge 2 commits into
Open
talelboussetta wants to merge 2 commits into
talelboussetta wants to merge 2 commits into
Conversation
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.
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
text_modeappends--disable-javascriptto Chromium's flags (both flag builders inbrowser_manager.py). Chromium has no such switch and ignores it, sotext_modehas 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 withBrowserConfig(java_script_enabled=False), which sets it on the browser context.This removes the entry and says in the
text_modedocs 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.mdstill 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-javascriptfromManagedBrowser.build_browser_flags()andBrowserManager._build_browser_args().crawl4ai/async_configs.py,docs/md_v2/core/browser-crawler-config.md: one line saying JavaScript still runs undertext_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?
The offline suites (
deploy/docker/testswithout the live-servertest_1–test_7scripts,tests/unit, the pool tests) show no new failures againstdevelop.That the switch does nothing, on an image built from
develop@ 1f68e5b, which still passes it:/crawlof a page on a local test site, soCRAWL4AI_ALLOW_INTERNAL_URLS=true, whose inline and external scripts each replace a heading. The values are the headings' text in the returned HTML.cc @ntohidi
Checklist: