Single Page App with react framework + webpack, cannot load the chunk JS

Let say I have a SPA, homepage URL is www.localhost.com.
When I clicked on the button in the page, www.localhost.com/button will display in the browser address bar.
Under the chrome devtool -> network tab, I only can observe https://www.localhost.com/static/js/8.5378837b.chunk.js is loaded.

The question, when I use the k6 http.get method to call www.localhost.com/button URL, I noticed the content of the page is not showing https://www.localhost.com/static/js/8.5378837b.chunk.js response data, how can not just hard code this URL because when there is a new deployment, the JS filename will changes. How can i overcome this issue?

Hi @xyngfei!

In this case, you’d have to parse the response for the url to use. Given the url pattern, something like

result.body.match(/localhost.com\/static\/js\/(.*)\.chunk\.js$/)

should be enough to capture the dynamic part of your filename.

(I’ve not tested this regex, so you might have to tweak it to get it to work)

Best,
Simme

This is a good method. However, the previous request may not have this xxx.chunk.js filename to make the next request

For example, look at this button, when you click on it will load another xxx.chunk.js file. I don’t see any js link can extract. Any better suggestion?