Skip to content

Commit 78d7b37

Browse files
committed
try to improve the documentation of the different options to disable the JS engine
1 parent 3a81693 commit 78d7b37

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/site/xdoc/javascript-howto.xml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,30 @@
3030

3131
<section name="Enable/Disable JavaScript support">
3232
<p>
33-
JavaScript support is enabled per default like in real browsers.
33+
The JavaScript support is enabled per default like in real browsers.
3434
</p>
35+
36+
<subsection name="Handling of JavaScript errors">
3537
<p>
36-
<s>But:</s> There is one major difference - in the default configuration HtmlUnit will
38+
<strong>But:</strong> There is one major difference compared to real browsers - in
39+
the default configuration HtmlUnit will
3740
stop JavaScript execution if an unhandled JavaScript error occurs. This is done
3841
because HtmlUnit was initially designed for testing where fail early is
3942
a good practice.<br></br>
4043
You can change this to silently (HtmlUnit will still log the exceptions)
41-
ignore them (like in real browsers) by setting
44+
ignore the JavaScript exceptions (like in real browsers) by setting
4245
the option throwExceptionOnScriptError to false.
4346
</p>
4447
<source><![CDATA[
4548
final WebClient webClient = new WebClient();
4649
webClient.getOptions.setThrowExceptionOnScriptError(false);
4750
]]></source>
51+
</subsection>
4852

53+
<subsection name="Completely disable the JavaScript support">
4954
<p>
5055
For some use cases it might be helpful to completely disable the JavaScript support
51-
(e.g. for better performance).
56+
(e.g. for better performance and less memory usage).
5257
HtmlUnit offers two way to do this; you can completely disable JavaScript or only
5358
temporary.<br></br>
5459
To disable the JavaScript support (without the possibility to enable it for the WebClient
@@ -58,17 +63,22 @@
5863
<source><![CDATA[
5964
WebClient webClient = new WebClient(BrowserVersion.FIREFOX, false, null, -1);
6065
]]></source>
66+
</subsection>
67+
68+
<subsection name="Temporary disable the JavaScript support">
6169
<p>
62-
By using the WebClientOptions it is possible to disable and re-enable the JavaScript support
63-
at any time for a given client. Doing this will only stop executing the script tags
64-
and triggering any event listeners.
70+
By using the WebClientOptions it is possible to disable JavaScript support for a specific client
71+
at any time and enable it again later.
72+
However, this only disables the execution of the script tags and the triggering of event listeners.
73+
However, the JavaScript objects will still be created.
6574
</p>
6675
<source><![CDATA[
6776
final WebClient webClient = new WebClient(BrowserVersion.FIREFOX);
6877
webClient.getOptions.setJavaScriptEnabled(false);
6978
....
7079
webClient.getOptions.setJavaScriptEnabled(true);
7180
]]></source>
81+
</subsection>
7282
</section>
7383

7484
<section name="Example: using Document.write()">

0 commit comments

Comments
 (0)