$this->view->headScript()->appendFile('/static/js/script1.js'); $this->view->headScript()->appendFile('/static/js/script2.js'); $this->view->headScript()->appendFile('/static/js/script3.js');
<script type="text/javascript" src="/static/js/script1.js"></script> <script type="text/javascript" src="/static/js/script2.js"></script> <script type="text/javascript" src="/static/js/script3.js"></script>
<script type="text/javascript" src="/static/cache/bff149a0b87f5b0e00d9dd364e9ddaa0.js"></script>
require: { "denis-isaev/zend-view-helper-head-concatenate": "*@dev" }, "repositories":[ { "type":"git", "url":"http://github.com/denis-isaev/ZendHeadConcat" } ]
$view->addHelperPath(APPLICATION_PATH . '/../vendor/denis-isaev/zend-view-helper-head-concatenate/library/Iden/View/Helper/', 'Iden_View_Helper');
resources.view.concatenateHeadScript.enable = true resources.view.concatenateHeadScript.cacheDir = APPLICATION_PATH "/../static/cache/" resources.view.concatenateHeadScript.cacheUri = /static/cache/ resources.view.concatenateHeadScript.map./static = APPLICATION_PATH "/../static"
resources.view.concatenateHeadScript.map./uri_path = APPLICATION_PATH "/../file_path"
means that for a script added with this URL:
$this->view->headScript()->appendFile('/uri_path/js/script1.js');
the file will be taken along the path:
APPLICATION_PATH "/../file_path/js/script1.js"
resources.view.concatenateHeadScript.map./static = APPLICATION_PATH "/../static" $this->view->headScript()->appendFile('/static/js/script1.js');
the file will be taken along the path:
APPLICATION_PATH "/../static/js/script1.js"
resources.view.concatenateHeadLink.map./static = APPLICATION_PATH "/../static" resources.view.concatenateHeadLink.map./admin/static = APPLICATION_PATH "/../cms_static"
resources.view.concatenateHeadLink.map./static = APPLICATION_PATH "/../static" resources.view.concatenateHeadLink.map./static/admin = APPLICATION_PATH "/../cms_static"
because in this case, urls that fit the second rule also fit the first.
<?php echo $this->concatenateHeadScript(); ?>
<script type="text/javascript" src="/static/cache/bff149a0b87f5b0e00d9dd364e9ddaa0.js"></script>
bff149a0b87f5b0e00d9dd364e9ddaa0.js
file is the union of all scripts.
application/javascript
) and the condition ( lt IE 7
), similar to how they are specified in the appendFile
method of the appendFile
helper:
<?php echo $this->concatenateHeadScript('application/javascript', array('conditional' => 'lt IE 7')); ?>
<!--[if lt IE 7]><script type="application/javascript" src="/static/cache/bff149a0b87f5b0e00d9dd364e9ddaa0.js"></script><![endif]-->
$this->view->headScript()->appendFile('/static/script_no_concat.js');
You can specify the parameter noConcat, so that this script is inserted into the html with a separate tag. In this case, all files that were added before this file will be merged into one cache file, then script_no_concat.js
will be inserted, then all scripts that were added after it will be merged into the second cache file, which will be added next:
$this->view->headScript()->appendFile('/static/js/script1.js'); $this->view->headScript()->appendFile('/static/js/script2.js'); $this->view->headScript()->appendFile('/static/js/script_no_concat.js', null, array('noConcat' => true)); $this->view->headScript()->appendFile('/static/js/script3.js'); $this->view->headScript()->appendFile('/static/js/script4.js');
<script type="text/javascript" src="/static/js/ecb97ffafc1798cd2f67fcbc37226761.js"></script> <script type="text/javascript" src="/static/js/script_no_concat.js"></script> <script type="text/javascript" src="/static/js/41f6175cdfe80c87b5bad623eb90ad33.js"></script>
$this->view->headScript()->appendFile('/static/script1.js', 'application/javascript'); $this->view->headScript()->appendFile('/static/script2.js'); // text/javascript $this->view->headScript()->appendFile('/static/script3.js', 'application/javascript'); $this->view->headScript()->appendFile('/static/script4.js'); // text/javascript
application/javascript
: <?php echo $this->concatenateHeadScript('application/javascript'); ?>
<script type="application/javascript" src="/static/js/ecb97ffafc1798cd2f67fcbc37226761.js"></script> <!-- script2.js --> <script type="text/javascript" src="/static/js/script2.js"></script> <script type="application/javascript" src="/static/js/41f6175cdfe80c87b5bad623eb90ad33.js"></script> <!-- script2.js script4.js --> <script type="text/javascript" src="/static/js/script4.js"></script>
<?php echo $this->concatenateHeadScript(); ?>
<script type="application/javascript" src="/static/js/script1.js"></script> <script type="text/javascript" src="/static/js/41f6175cdfe80c87b5bad623eb90ad33.js"></script> <!-- script1.js script3.js --> <script type="application/javascript" src="/static/js/script3.js"></script> <script type="text/javascript" src="/static/js/ecb97ffafc1798cd2f67fcbc37226761.js"></script> <!-- script3.js -->
resources.view.concatenateHeadLink.enable = true resources.view.concatenateHeadLink.cacheDir = APPLICATION_PATH "/../static/cache/" resources.view.concatenateHeadLink.cacheUri = /static/cache/ resources.view.concatenateHeadLink.map./static = APPLICATION_PATH "/../static"
$this->view->headLink()->appendStylesheet('/static/css/style1.css'); $this->view->headLink()->appendStylesheet('/static/css/style2.css'); $this->view->headLink()->appendStylesheet('/static/css/style3.css');
<?php echo $this->concatenateHeadStylesheet(); ?>
<link href="/static/cache/4e0eb351038628091ac42188b1e92977.css" media="screen" rel="stylesheet" type="text/css" >
<?php echo $this->concatenateHeadStylesheet('tv', 'lt IE 9'); ?>
<!--[if lt IE 9]> <link href="/static/cache/4e0eb351038628091ac42188b1e92977.css" media="tv" rel="stylesheet" type="text/css" > <![endif]-->
$this->view->headLink()->appendStylesheet('/static/css/style1.css', null, null, $extras);
It is automatically marked as noConcat.
$this->view->headLink()->appendStylesheet('/static/css/style1.css', 'tv');
different from media (application / javascript) final css <?php echo $this->concatenateHeadStylesheet('application/javascript'); ?>
such a file is marked as noConcat.
$this->view->headLink()->appendStylesheet('/static/css/style1.css', null, 'lt IE 9');
The file is marked as noConcat.
$this->view->headLink()->appendStylesheet('/static/css/style1.css', null, null, array('noConcat' => true));
Source: https://habr.com/ru/post/212897/