HTTP request to retrieve all embeded resources

In jmeter, there is an option to allow the HTTP request to retrieve all embeded resources. How can I write the code in k6?

Hi @xyngfei,
I would advice that you record your session in the browser and than use the generated file.

Alternatively you can parse the html and then make batch requests for the parts you want, but that will be … much harder and error prone. Also won’t catch any cases where because of JS on the page somethings have been loaded (I suppose jmeter misses those as well though).

So session recording and possibly manual editing of the script will be “much” easier to do.

I did try to use the loadimpact chrome extension, however some of the filename resources is very unique. How do i overcome this issue?


Not sure I understand what you mean about unique filename resources, but the link you’ve pasted is for the old chrome extension. This is the new one: k6 Documentation
And the link @mstoykov sent describes how to record HAR files without the extension: Using the HAR converter

1 Like


Thanks for your info.
However, the HAR recording doesn’t solve the unique filename issue which is generated by the webpack bundle. Do you have any better way to handle this issue?

Sorry for the late reply. In essence, if you have dynamic file names, you’d have to modify the resulting JS code to handle these cases. Specifically, as @mstoykov also pointed out, if the dynamic path to the webpack bundle is in a <script> tag, you can probably extract it by using the k6 HTML parsing API: parseHTML( src )

Thanks @ned

For others info, you can use the method below to get all the script src info:-

const req_script = parseHTML(res.body);
req_script.find(‘script’).toArray().forEach(function (item) {
// do something