Inline static assets
Inlining static assets refers to embedding the content of a static asset directly in an HTML or JS file instead of linking to an external file. This can improve website performance by reducing the number of HTTP requests the browser needs to make to load the page.
However, inlining static assets has some disadvantages, such as increasing the size of a single file, which may lead to slower loading. Decide whether to inline assets based on your specific situation.
Rsbuild automatically inlines static assets of 4KiB or less. This guide shows how to change that threshold, force inlining, or disable it for specific assets.
Automatic inlining
Rsbuild inlines assets whose size does not exceed the threshold (4KiB by default). These assets become Base64 strings and need no separate HTTP request. Larger assets are emitted as separate files and loaded through their own HTTP requests.
You can modify the threshold with the output.dataUriLimit config. For example, set the threshold for images to 5000 bytes and disable inlining for media assets:
Force inlining
You can force an asset to be inlined by adding the inline query parameter when importing it, regardless of the asset's size.
In the above example, the foo.png image will always be inlined, regardless of the image size.
Referenced from CSS file
When you reference a static asset in your CSS file, you can also force it to inline with the inline query parameter.
Inlining large assets will significantly increase the first paint time or first contentful paint time of a page, degrading user experience. If you inline a static asset multiple times in a CSS file, the base64 content will be injected repeatedly, increasing bundle size. Use forced inlining with caution.
Disable inlining
To prevent assets from being inlined and ensure they're always loaded as separate files (regardless of their size), add the url query parameter.
In the above example, the foo.png image will always be loaded as a separate file, even if it's smaller than the threshold.
Referenced from CSS file
When you reference a static asset in your CSS file, you can also prevent inlining with the url query parameter.
Disabling asset inlining will increase the number of assets the web application needs to load. This will reduce loading efficiency in weak network environments or scenarios where HTTP/2 is not enabled. Use with caution.
Inline JS files
In addition to inlining static assets into JS files, Rsbuild also supports inlining JS files into HTML files.
Enable output.inlineScripts to inline scripts referenced by the generated HTML during production builds. Inlined files are removed from the output directory. Async chunks remain separate files.
Inline JS files may cause the HTML file to become too large and will break HTTP caching. Use with caution.
Inline CSS files
You can also inline CSS files into HTML files.
Enable output.inlineStyles to inline stylesheets referenced by the generated HTML during production builds. Inlined files are removed from the output directory. CSS loaded by async chunks remains in separate files.
Type declaration
When you use URL queries such as ?inline and ?url in TypeScript code, TypeScript may prompt that the module is missing a type definition:
To fix this, use one of the following methods:
- Method 1: If the
@rsbuild/corepackage is installed, you can add the preset types provided by@rsbuild/coretotsconfig.json:
- Method 2: Manually add the required type declarations:

