# Assets

## Public API

WebIO.AssetType
Asset(url)
Asset(name, url)
Asset(name => url)
Asset(filetype, name, url)

A browser asset that can be loaded by WebIO.

The url parameter may be either a remote URL or a local filepath (which will be served via AssetRegistry.jl). All of the following are valid url values.

• https://unpkg.com/react@16/umd/react.development.js
• //unpkg.com/react@16/umd/react.development.js
• ./path/to/foo.js

By default, the filetype is guessed as the extension of the specified url (only "js", "css", and "html" are currently supported) but may be specified if nonstandard extensions are in use.

source
WebIO.AsyncType
Async(assets...)

A group ("block") of assets that will be imported with no specified order (asynchronously) in the browser. This is useful when dependencies can be imported in any order. The elements of assets may either be Assets themselves, any valid constructor for an Asset, or a Sync or Async.

If the imports need to be imported sequentially, use Sync instead.

source
WebIO.SyncType
Sync(assets...)

A group ("block") of assets that will be imported sequentially (synchronously) in the browser. This is useful when dependencies have side effects that must be executed in order. The elements of assets may either be Assets themselves, any valid constructor for an Asset, or a Sync or Async.

If the imports do not need to be imported sequentially, use Async instead.

Examples

julia> WebIO.Sync(Asset("foo.js"), "bar" => "bar.js")
Sync(Asset[Asset("js", nothing, "foo.js"), Asset("js", "bar", "bar.js")])
source

## Private API

WebIO.dep2urlFunction
dep2url(dep)

Return the URL where the dependency can be fetched from. If the dependency is a URL (e.g. hosted at a CDN), the same URL is returned. Otherwise, the depency is registered with AssetRegistry.jl and served from there.

source
WebIO.getextensionFunction
getextension(path)

Get the file extension of the path. The extension is defined to be the bit after the last dot, excluding any query string.

Examples

julia> WebIO.getextension("foo.bar.js")
"js"
julia> WebIO.getextension("https://my-cdn.net/foo.bar.css?version=1")
"css"
source
WebIO.islocalFunction
islocal(path)

Determine whether or not the specified path is a local filesystem path (and not a remote resource that is hosted on, for example, a CDN).

source
WebIO.path2urlFunction
path2url(path)

Register the specified path with AssetRegistry and return the url that corresponds to that path.

Examples

julia> WebIO.path2url(expanduser("~/Documents/foo.js"))
"/assetserver/bd67c48cbe6388c22f85faef9840ff9a2dfc1df6-foo.js"
source