- All Implemented Interfaces:
Serializable
,Comparable<Script>
A script is identified by URI, but has other constraints. Including:
- an async attribute
- an defer attribute
- an optional crossorigin attribute
- TODO: Add more attributes as-needed
Optimizers should be careful to only group stylesheets that have equivalent constraints.
TODO: Support inline scripts without URI (defer and async not allowed for inline).
TODO: Support modules.
- Author:
- AO Industries, Inc.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder pattern forScript
.static enum
The set of allowed script locations. -
Field Summary
Modifier and TypeFieldDescriptionstatic final Comparator
<Script> Scripts start with a default ordering that should minimize the number of explicit ordering declarations. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Script.Builder
builder()
int
All concrete implementations of Resource must be comparable to themselves.boolean
Two resources may be compared to see if they are exactly equal, including all relevant attributes.Gets the optional crossorigin policy.Gets this script position.int
hashCode()
The hash key must be consistent withResource.equals(java.lang.Object)
.boolean
isAsync()
Gets this script is asynchronous.boolean
isDefer()
Gets this script is deferred.toString()
-
Field Details
-
COMPARATOR
Scripts start with a default ordering that should minimize the number of explicit ordering declarations.Note: The crossorigin policy is not used in ordering.
All string comparisons are performed via
SmartComparator.ROOT
.
-
-
Constructor Details
-
Script
public Script(String src, Script.Position position, boolean async, boolean defer, String crossorigin) Creates a new script.- Parameters:
src
- SeeResource.getUri()
position
- SeegetPosition()
async
- SeeisAsync()
defer
- SeeisDefer()
crossorigin
- SeegetCrossorigin()
-
Script
Creates a new script.- Parameters:
src
- SeeResource.getUri()
-
-
Method Details
-
builder
-
toString
-
equals
Description copied from class:Resource
Two resources may be compared to see if they are exactly equal, including all relevant attributes. -
hashCode
public int hashCode()Description copied from class:Resource
The hash key must be consistent withResource.equals(java.lang.Object)
. -
compareTo
All concrete implementations of Resource must be comparable to themselves.This default implementation compares by URI only via
SmartComparator.ROOT
. -
getPosition
Gets this script position. -
isAsync
public boolean isAsync()Gets this script is asynchronous. -
isDefer
public boolean isDefer()Gets this script is deferred. -
getCrossorigin
Gets the optional crossorigin policy.
-