Javascript 加载具有优先级的字体
我正在开发商业应用程序,希望优化某些网页的性能。我已经完成了所有必需的更改,但无法将test.fonts.css的优先级设置为高 jsp页面代码Javascript 加载具有优先级的字体,javascript,java,css,jsp,Javascript,Java,Css,Jsp,我正在开发商业应用程序,希望优化某些网页的性能。我已经完成了所有必需的更改,但无法将test.fonts.css的优先级设置为高 jsp页面代码 <%@ taglib prefix="mag" uri="mag-custom-taglib"%> <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%> <%@
<%@ taglib prefix="mag" uri="mag-custom-taglib"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<mag:cache-controlled-link href="/order/genome-database/assets/core/dist/fonts/test.fonts.css"/>
缓存控制的链接标记在其自己的标记库描述符文件中定义
<tag>
<name>cache-controlled-link</name>
<tagclass>core.jsp.tag.CacheControlledLink</tagclass>
<attribute>
<name>showVersion</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>showTimestamp</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>href</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
缓存控制链路
core.jsp.tag.CacheControlledLink
展示版
假的
真的
显示时间戳
假的
真的
href
真的
真的
tagclass即CacheControlledLink是一个java文件
public class CacheControlledLink extends CacheControlledAsset {
protected String href;
@Override
public int doStartTag() throws JspException {
try {
JspWriter out = pageContext.getOut();
String href = buildUrlToResource();
out.print("<link rel=\"stylesheet\" type=\"text/css\" href=\"");
out.print(href);
out.println("\"/>");
} catch (IOException e) {
logger.error("Unable to write CacheControlledLink tag to jsp:", e);
}
return SKIP_BODY;
}
public void setHref(String href) {
this.href = href;
}
@Override
protected String getUri() {
return href;
}
}
公共类CacheControlledLink扩展CacheControlledAsset{
受保护字符串href;
@凌驾
public int doStartTag()抛出JSPEException{
试一试{
JspWriter out=pageContext.getOut();
String href=buildUrlToResource();
输出。打印(“”);
}捕获(IOE异常){
logger.error(“无法将CacheControlledLink标记写入jsp:,e”);
}
返回跳过单元体;
}
公共void setHref(字符串href){
this.href=href;
}
@凌驾
受保护的字符串getUri(){
返回href;
}
}
我知道要设置优先级,我必须使用rel=“preload”,但我不知道如何为target href设置该属性。我试图格式化href以添加“rel=”preload“,但得到“jasperexception-根据TLD标记无效”
设置优先级的最佳方法是什么
谢谢。当您使用
时,您似乎想设置一个额外的属性rel
。是的,我现在正在这样做,但是我的是不是可以为单个href设置一个属性,因为整个应用程序都在为不同的href使用缓存控制链接。