<- Test Directory

Automatically Load Page Resources

How to use LoadForge to automatically load page styles, javascript, images, etc.

Overview

LoadForge supports using the HttpUserWithResources plugin for Locust, allowing you to automatically fetch all relevant page resources.

We typically advise creating your test to manually include resources you wish to fetch, as this will not execute JS, so you may want to fetch AJAX resources. Or alternatively, you could upload a browser recording (.har) to achieve that same.

Example Code

from locust_plugins.users import HttpUserWithResources
from locust import task


class TestUserWithResources(HttpUserWithResources):
    # these values can be overridden
    # bundle_resource_stats=False
    # default_resource_filter=".*[^(js)]$"

    @task
    def include_resources_default(self):
        self.client.get("/cart")

    @task
    def include_resources_true(self):
        self.client.get("/", resource_filter=".*[^(js|png|css|gif|woff)]$")

    @task
    def include_resources_false(self):
        self.client.get("/dashboard", include_resources=False)


This guide is part of the LoadForge Directory, an index of locustfile's for use with LoadForge website and API load tests. We also provide a wizard to generate tests, and onboarding assistance for clients. Contact us should you have any questions.

LoadForge provides load testing and stress tests for websites, APIs and servers. It uses your cloud account to rapidly scale large numbers of simulated users to load test your website, store, API, or application for cheap - just cents per test!

For more help on Tests please see our official documentation. Logged in users can also use our wizard to generate a locustfile, or you can record your browser steps.

Ready to run your test?
Start your first test within minutes.