@Component(value="blResourcePreloadProcessor") @ConditionalOnTemplating public class ResourcePreloadProcessor extends AbstractResourceProcessor
This is useful in combination with bundling where one bundle might depend on another and must wait for the other to finish before it can be added to the DOM. Since the script isn't immediately in the DOM, the browser doesn't download the resource until it's added to the DOM, increasing the time before the bundle can be used.
This processor adds preload link tags which tell the browser to preload (download) a resource even though it isn't yet in the DOM. Doing so decreases the latency when the script is ready to execute.
This processor has the ability to retrieve a bundle that has already been requested earlier in the template
looking it up with the bundle name. See ResourcesRequest for
more information. This helps with not having to duplicate the bundle information across the <blc:bundlepreload>
and <blc:bundle> tags.
The <bundlepreload> accepts all the parameters that ResourceBundleProcessor accepts, but will only ever
use them if they are relevant to generating the bundle.
bundlingService, environment, resourcesRequest| Constructor and Description |
|---|
ResourcePreloadProcessor() |
| Modifier and Type | Method and Description |
|---|---|
protected org.broadleafcommerce.presentation.model.BroadleafTemplateModel |
buildModelBundled(List<String> attributeFiles,
ResourceTagAttributes resourceTagAttributes,
org.broadleafcommerce.presentation.model.BroadleafTemplateContext context)
Builds the model that contains the bundled resources the tag should be replaced with
|
protected org.broadleafcommerce.presentation.model.BroadleafTemplateModel |
buildModelUnbundled(List<String> attributeFiles,
ResourceTagAttributes resourceTagAttributes,
org.broadleafcommerce.presentation.model.BroadleafTemplateContext context)
Builds the model that contains the unbundled resources the tag should be replaced with
|
protected org.broadleafcommerce.presentation.model.BroadleafTemplateElement |
buildPreloadElement(String href,
org.broadleafcommerce.presentation.model.BroadleafTemplateContext context)
Builds a preload link for the given path
|
protected String |
getAs(String file)
Gets the "as" attribute for the link based off of the file name
|
String |
getName() |
int |
getPrecedence() |
protected Map<String,String> |
getPreloadAttributes(String href,
String as)
Builds a map of the attributes that should be put on the <link> tag.
|
buildBundledFilesList, buildResourceTagAttributes, getBundleAppendText, getBundleCompleteEventJavaScript, getBundleEnabled, getBundlePath, getBundleUrl, getFullUnbundledFileName, getReplacementModel, getRequestedFileNames, postProcessUnbundledFileList, validateTagAttributespublic String getName()
public int getPrecedence()
getPrecedence in interface org.broadleafcommerce.presentation.dialect.BroadleafProcessorgetPrecedence in class org.broadleafcommerce.presentation.dialect.AbstractBroadleafTagReplacementProcessorprotected org.broadleafcommerce.presentation.model.BroadleafTemplateModel buildModelBundled(List<String> attributeFiles, ResourceTagAttributes resourceTagAttributes, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context)
AbstractResourceProcessorbuildModelBundled in class AbstractResourceProcessorattributeFiles - list of files that are to be bundledresourceTagAttributes - the attributes of the original tag this processor replacescontext - the context of the original tagprotected org.broadleafcommerce.presentation.model.BroadleafTemplateModel buildModelUnbundled(List<String> attributeFiles, ResourceTagAttributes resourceTagAttributes, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context)
AbstractResourceProcessorbuildModelUnbundled in class AbstractResourceProcessorattributeFiles - list of files that are to be includedresourceTagAttributes - the attributes of the original tag this processor replacescontext - the context of the original tagprotected org.broadleafcommerce.presentation.model.BroadleafTemplateElement buildPreloadElement(String href, org.broadleafcommerce.presentation.model.BroadleafTemplateContext context)
href - the path of the file to create the link withcontext - the context of the bundlepreload tagprotected Map<String,String> getPreloadAttributes(String href, String as)
href - the href of the resource to preloadas - the value the "as" attribute should have or null if it shouldn't be includedCopyright © 2019. All rights reserved.