Download the PHP package istranger/yii2-resource-smart-load without Composer

On this page you can find all versions of the php package istranger/yii2-resource-smart-load. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-resource-smart-load

Extension to prevent reloading JS/CSS resources (on AJAX request)

This extension for Yii 2 prevent reload resources (on AJAX request), which already exist on client. Similar extension for yii 1.1.x. This extension has more functionality than the Yii 2 native resource filter, see detail

Requirements

Features

Limitations

Installation

Usage

Typical use case

By default, this extension disables reloading of js files only, css files and js/css inline blocks not tracked (see option resourceTypes). But you can (carefully!) disable other resources types.

That is, each "tracked" resource on the page will be loaded only once, even if it will later be removed from this page. Therefore, all JS callbacks on first load should be bind to the global containers (for example, document) using jQuery-method .on().

At the subsequent AJAX requests already loaded CSS inline blocks (or CSS files) may be replaced by new content, therefore, in case you have problems with several CSS styles you configure exclusions (see below).

Advanced use case

For the analysis of disabled/loaded scripts is convenient to use an option enableLog, that output useful debug information in browser console:

You can more flexible manage resource loading on certain pages using methods (see examples):

These methods can be invoked in any actions. The argument $types is an array of tracked resource types, that should be excluded from the page. By default (=null), tracked all types.
Array can be defined using constants:

This restriction has higher priority than $resourceList.

In addition, you can set activateOnAllPages = false, and extension will be disabled on all pages. You will need to manually configure disabling of resources on certain pages (with the help of these methods).

Alternatively, you can configure exclusion list of resources:

These resources always will be loaded on client. Each resource can be presented:

The hash of specific resource can be get through browser console in the global object of extension (enableLog == true). For example:

Examples

Examples of usage in controller actions (it is assumed that activateOnAllPages = false).

Disable load of all CSS inline blocks:

Note: specified resources will be excluded from the page for all requests (not only AJAX).

Disable load of certain resources files (for all AJAX requests):

Note: at normal request (not AJAX) these files will be included into page.

Disable load of certain resources files with restriction by type:

Note: will be disabled only , because restriction by type has higher priority than $resourceList.

Disable load of JS inline blocks and JS files, which already exist on client:

Note: resources can be disabled only on AJAX request.

Disable load of all resources, which already exist on client:

Tests

Tests will be later.

Similar extensions. Native resource filtration script

To prevent reloading scripts for Yii 1.1.x you can use nlsclientscript.

Similar approach used in Yii 2 core.

However, there are a few differences:

Our extension does not interfere with native filter. They can be used together or separately. In our extension option disableNativeScriptFilter can partial disable native filter (if necessary).


All versions of yii2-resource-smart-load with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package istranger/yii2-resource-smart-load contains the following files

Loading the files please wait ....