Origami Frontend Components & Services

Readme: o-assets

This component provides Sass and JavaScript utilities for reliably building paths to a component's static assets, such as CSS background images, fonts and JSON data files. This is needed because the URL path to load these assets will vary depending on how a product developer chooses to integrate the Origami component into their website.


If a component called o-example contains a stylesheet that loads a logo as a background, and that image exists at /img/logo.png in the component's git repository, the path that needs to be output in the CSS could vary:

  1. https://origami-build.ft.com/v2/files/o-example@1.2/img/logo.png - If the product developer uses the build service to fetch the CSS, it needs to send the request for the logo back through the build service, and also needs to know what version of the component the CSS came from so it can serve the logo image from the same version.
  2. /bower_components/o-example/logo.png - If the product developer has installed the Origami components in a bower_components directory (which is typical) and that directory is at the root of their web server's public document tree, the default variable values will make the subresources Just Work™
  3. /resources/head/logo.png - If the product developer has a front-controller and can therefore internally map resource request URLs to different paths on the filesystem, and perhaps also wants to rename the component name component to something of their choosing, they might want the path to be something like this.

When loading from installed components there is no need for a version number because the subresource file will be part of the same installed package from which the CSS or JavaScript is drawn.

Where you need to resolve a path use the resolve methods, which take the path relative to the component root directory and component name as arguments:


background: url(oAssetsResolve("img/symbols-sprite.png", o-weather));


import { resolve } from 'o-assets';
xhr.open("get", resolve('data/2013/12/monthdata.csv', 'o-weather'));

URL routing

'URL routing' is used as a generic term for any method used to point a url to a resource, including copying the resource to the location specified by the url.

If you don't have URL routing

If your web server is serving files directly from disk with no routing layer, and therefore URL paths map directly to filesystem paths, then Origami assets should load correctly by default, provided that you:

If you do have URL routing

If you have URL routing and you want to improve on the above (because it's generally inadvisable to put bower_components in a public area of your web server), you can configure the assets component to load assets from a different path. The path to a given resource is composed by doing the following concatenation by default:

$o-assets-global-path + {component-name} + / + {path-within-repo}

By default the global path is /bower_components/, which anticipates that you will put your local bower components directory in the public web root of your web server. However, as well as editing this, you can also set a custom path to any component, in whcih case the path for that component becomes:

{custom-path} + {path-within-repo}

Note that when you set a custom path for a component, the global path prefix is not used (but is still used for any components for which you have not set a custom path).

Any custom configuration should be set before including any other components in your product's sass/js bundles.

  1. Global path prefix: $o-assets-global-path variable (in Sass) and setGlobalPathPrefix method (in JavaScript). Default is '/bower_components/'.
  2. component path: This defaults to the name of the component and is set using methods that accept a map of component names and paths:


@include oAssetsSetcomponentPaths((
    'o-example': '/assets/example'


import { setcomponentPaths } from 'o-assets';
    'o-example': '/assets/example'

Using with the build service

If you don't want to make local static assets available publicly, but you want to benefit from including Origami component CSS and JS into your own build, you can use the build service for your local assets. To do this, you will need to configure paths that include the version of the component that you installed, because otherwise the build service might give you assets from a different version of the component to the one you have. This is a significant gotcha, especially if you have non-shrinkwrapped Origami dependencies. Make sure your asset resource paths match the version you actually installed.

import { setcomponentPaths } from 'o-assets';
    'o-example': '//origami-build.ft.com/v2/files/o-example@1.2.3',
    'o-grid': '//origami-build.ft.com/v2/files/o-grid@2.3.4'


If you have any questions or comments about this component, or need help using it, please either raise an issue, visit #ft-origami or email Origami Support.


This software is published by the Financial Times under the MIT licence.

active Origami v1
Switch component view

GitHub Repository

Install o-assets

If using the Build Service, add o-assets@^3.4.2 to your script and link tags.

If running a Manual Build, run npm install "o-assets@^3.4.2".

Help & Support

o-assets is maintained directly by the Origami team. If you have any questions about o-assets or Origami in general, we are happy to help. 😊

Slack: #ft-origami
Email: origami.support@ft.com

Feedback / Issues

To report a bug or request features please create an issue on Github. For support or general feedback please get in touch 😊

Slack: #ft-origami
Email: origami.support@ft.com