preload

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package preload defines representations of preload links.

Index

Constants

View Source
const (
	AsAudio    = "audio"
	AsDocument = "document"
	AsEmbed    = "embed"
	AsFetch    = "fetch"
	AsFont     = "font"
	AsImage    = "image"
	AsObject   = "object"
	AsScript   = "script"
	AsStyle    = "style"
	AsTrack    = "track"
	AsWorker   = "worker"
	AsVideo    = "video"
)

Values for the "as" attribute of preload links.

Variables

This section is empty.

Functions

This section is empty.

Types

type Preload

type Preload struct {
	*httplink.Link

	// Resources contains a set of resources referenced by the preload link.
	// It typically consists just of one resource, but contains multiple
	// resources when the preload offers more than one option, such as images
	// with multi-source ("imagesrcset") or content negotiations ("variants").
	Resources []*resource.Resource
}

Preload represents a preload link.

func NewPreloadForLink(link *httplink.Link) *Preload

NewPreloadForLink creates and initializes a new Preload to perform the preloading as specified by link. The new Preload is populated with a new single Resource requesting to link.URL. Note it implies link.URL should be absolute.

NewPreloadForLink assumes link.IsPreload() to be true.

func NewPreloadForResource

func NewPreloadForResource(r *resource.Resource, as string) *Preload

NewPreloadForResource creates and initializes a new Preload to preload a single Resource.

as specifies the "as" parameter value. If it is empty, the parameter is kept unset.

func NewPreloadForURL

func NewPreloadForURL(u *url.URL, as string) *Preload

NewPreloadForURL creates and initializes a new Preload to preload u. The new Preload is populated with a new single Resource requesting to u. Note it implies u should be absolute.

as specifies the "as" parameter value. If it is empty, the parameter is kept unset.

Directories

Path Synopsis
Package preloadtest provides utilities for preload link testing.
Package preloadtest provides utilities for preload link testing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL