For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Dev Portal
DocsAPI ReferenceLearnCommunityChangelog
DocsAPI ReferenceLearnCommunityChangelog
  • Overview
    • Quick Start
    • Sandboxes
    • Tools & SDKs
    • Support
  • Docs
      • Getting Started
        • Overview
          • Performance Optimization
          • Using Early Hints
          • Checking a Theme's Size
          • Uploading a Theme
          • Upload Errors
          • Updates and Version Control
          • Theme Metadata: Images
        • B2B Edition for Stencil
    • Archive
    • Closed Beta Programs
Dev Portal
LogoLogo
On this page
  • Theme assets that are automatically optimized
  • Script Manager scripts
  • Stylesheets & Fonts
  • Theme assets that require manual updates
  • Theme scripts loaded using the cdn Handlebars helper
  • How to choose which scripts to preload
DocsStorefrontStencilDeployment

Early Hints

Was this page helpful?
Previous

Performance Optimization

Next

Checking a Theme's Size

Built with

Early Hints reduces page load time and perceived latency by allowing browsers to download critical assets earlier in the request lifecycle. When a server uses Early Hints, the server indicates which site assets (such as CSS files, JS scripts, and fonts) a browser needs to render a page fully. When a client requests a site, the server responds with a 103 Early Hints response containing the essential assets. The client begins to load these assets while the server compiles and returns the 200 OK response to the client.

For more details on Early Hints, see An HTTP Status Code for Indicating Hints. Because Stencil’s implementation of Early Hints relies on using the Cloudflare CDN, also read Early Hints: How Cloudflare Can Improve Website Load Times by 30%.

While many of Stencil’s assets are automatically optimized to use Early Hints, some assets require theme updates. The following sections detail what assets are automatically optimized and which require theme updates.

Theme assets that are automatically optimized

Script Manager scripts

Developers don’t need to make any theme updates to take advantage of Early Hints on Script Manager scripts that are required to render a page.

If the store is not using the Cookie Consent feature, BigCommerce marks all scripts for preloading.

If a store uses the Cookie Consent feature, BigCommerce only marks scripts marked as Essential for preloading. Essential scripts load on all pages for all shoppers.

Stylesheets & Fonts

Assets loaded through the {{stylesheet}} or {{getFontsCollection}} Handlebars helpers are automatically marked for preloading.

Theme assets that require manual updates

Theme scripts loaded using the cdn Handlebars helper

JavaScript files within themes, such as the primary JavaScript bundle, are typically loaded using the cdn helper.

To take advantage of Early Hints, theme developers must mark the highest-priority resources within their theme for preloading by adding the resourceHint, rel, and cors arguments to the {{cdn}} helper. For detailed information, see {{cdn}} on the Handlebars helpers reference.

The following is an example of using the Early Hints arguments on the {{cdn}} helper:

Before
<script async src="{{cdn 'assets/dist/theme-bundle.head_async.js'}}"></script>
After
<script async src="{{cdn 'assets/dist/theme-bundle.head_async.js' resourceHint='preload' as='script'}}"></script>

How to choose which scripts to preload

Developers should only mark a script for preloading if that script is responsible for painting the page and loading the above-the-fold content. Non-critical scripts should be deferred instead of preloaded.