Skip to content

Commit aa3ac06

Browse files
committed
Move the advanced module API admonition closer to section start and
refine messaging
1 parent ccc126d commit aa3ac06

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

docs/sources/k6/next/extensions/create/javascript-extensions.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ INFO[0000] false, 1 is NOT greater than 3 source=console
161161

162162
## Use the advanced module API
163163

164+
{{< admonition type="caution" >}}
165+
166+
The advanced module API adds significant complexity to your extension. Consider whether you actually need access to internal
167+
k6 objects before implementing this pattern. For simple modules that don't need VU state or runtime access, the basic approach
168+
shown above is sufficient.
169+
170+
{{< /admonition >}}
171+
164172
Suppose your extension needs access to internal k6 objects to, for example, inspect the state of the test during execution.
165173
We will need to make slightly more complicated changes to the above example.
166174

@@ -174,12 +182,6 @@ to access the [`modules.VU`](https://pkg.go.dev/go.k6.io/k6/js/modules#VU) to in
174182
Additionally, there should be a root module implementation of the [`modules.Module`](https://pkg.go.dev/go.k6.io/k6/js/modules#Module)
175183
interface to serve as a factory of `Compare` instances for each VU.
176184

177-
{{< admonition type="caution" >}}
178-
179-
The significance depends on the size of your module.
180-
181-
{{< /admonition >}}
182-
183185
Here's what that would look like:
184186

185187
{{< code >}}

0 commit comments

Comments
 (0)