【问题标题】:Replace JavaScript included file with function用函数替换 JavaScript 包含的文件
【发布时间】:2017-05-14 05:33:51
【问题描述】:

有谁知道如何用函数替换包含的 js 文件 'modernizr.min.js'

{{ **'modernizr.min.js'** | asset_url | script_tag }}

功能:

;window.Modernizr=function(a,b,c){function z(a){j.cssText=a}function A(a,b){return z(m.join(a+";")+(b||""))}

【问题讨论】:

  • 不确定你的意思,如果你能在之前和之后显示代码会有帮助

标签: javascript performance include


【解决方案1】:
if(true)
{
var head  = document.getElementsByTagName('head')[0];
var link  = document.createElement('link');
link.rel  = 'stylesheet';
link.type = 'text/css';
link.href = 'http://website.com/css/stylesheet1.css';
head.appendChild(link);

}else{
var head  = document.getElementsByTagName('head')[0];
var link  = document.createElement('link');
link.rel  = 'stylesheet';
link.type = 'text/css';
link.href = 'http://website.com/css/stylesheet2.css';
head.appendChild(link);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-25
    • 2021-02-05
    • 1970-01-01
    • 2012-12-10
    • 2019-07-14
    • 2022-08-15
    相关资源
    最近更新 更多