multidomain-client-script Extension allows to use multiple domains (subdomains) for loading assets.

  1. Multidomain ClientScript (assets)
  2. Preinstall
  3. Install and config (available and default settings)
  4. Params
  5. Examples
  6. Requirements
  7. Resources

Multidomain ClientScript (assets) ΒΆ

Extending default Yii CClientScript class to use multiple subdomains for assets (scripts and stylesheets).

Preinstall ΒΆ

You should make sure, that your HTTP-server configured properly - 'assetsSubdomain' and all its combinations are pointing to your 'public_html' directory.

Install and config (available and default settings) ΒΆ

Place MultidomainClientScript.php file into protected/components directory. After this, you can enhance CClientScript class by making some changes in your config file (protected/config/main.php):

'components' => array(
   ...
    'clientScript' => array(
        'class' => 'application.components.MultidomainClientScript',
        'enableMultidomainAssets' => true,
        'assetsSubdomain' => 'assets',
        'indexedAssetsSubdomain' => false,
    ),
    ...
)

Params ΒΆ

  • enableMultidomainAssets - whether to use subdomains for ClientScript assets. Default is true
  • assetsSubdomain - subdomain name (e.g. 'http://assets.example.com'). Default is 'assets'
  • indexedAssetsSubdomain - whether to use indexed subdomains for registered script files basing on their 'position' param. Default is false

Examples ΒΆ

Example for indexedAssetsSubdomain=true param:

Yii::app()->clientScript->registerScriptFile('/js/script.js', CClientScript::POS_HEAD);

// will output:
<head>
    ...
    <script type="text/javascript" src="http://assets0.example.com/js/script.js"></script>
    ...
</head>
Yii::app()->clientScript->registerScriptFile('/js/script.js', CClientScript::POS_END)

// will output:
<body>
    ...
    <sсript type="text/javascript" src="http://assets2.example.com/js/script.js"></script>
</body>

Requirements ΒΆ

Yii since 1.1.7 or above.

Resources ΒΆ

8 0
7 followers
451 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Networking
Developed by: Borales Borales
Created on: Jan 3, 2013
Last updated: 13 years ago

Downloads

show all

Related Extensions