繁体   English   中英

如何在Cakephp中一次加载所有CSS和JS

[英]How to load all css and js at a time in Cakephp

如何在一个请求上加载所有CSS和JS

这是一个示例HTML文档,类似地包含许多CSS和JavaScript文件

<link rel =“ stylesheet” type =“ text / css” href =“ path / to / 960framework.css”>

<link rel =“ stylesheet” type =“ text / css” href =“ path / to / base.css”>

<link rel =“ stylesheet” type =“ text / css” href =“ path / to / navigations.css”>

<script type =“ text / javascript” src =“ path / to / jQuery.js”>

<script type =“ text / javascript” src =“ path / to / functions.js”>

<script type =“ text / javascript” src =“ path / to / handlers.js”>

... 多过

它的make 6请求,但我想一次加载所有js和css(仅一个请求)

所以我尝试

对于CSS

allStyles.css.php //

include(“ cssReset.css”);

include(“ 960framework.css”);

include(“ base.css”);

对于js

allScripts.js.php

include(“ jQuery.js”);

include(“ functions.js”);

include(“ handlers.js”);

include(“ ajax.js”);

include(“ navigations.css”);

然后打电话

<link rel =“ stylesheet” type =“ text / css” href =“ path / to / allStyles.css.php”>

<script type =“ text / javascript” src =“ path / to / allScripts.js.php”>

所有的js和CSS都已加载,但css和js却不担心n页?

php没有在响应中发送适当的内容类型标头。 因为您将这些行添加到页面顶部

<?php header("Content-type: text/css"); ?>
<?php header("Content-type: application/javascript"); ?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM