Download the PHP package lekoala/silverstripe-defer-backend without Composer

On this page you can find all versions of the php package lekoala/silverstripe-defer-backend. 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 silverstripe-defer-backend

SilverStripe Defer Backend module

Build Status scrutinizer Code coverage

Intro

This module allows you to define a backend that defers your script by default. As a nice bonus, it also allows you to set a simple content security policy by adding nonce to your scripts.

Defer your requirements

In order to defer your scripts, you need to replace in your PageController the default backend.

Once this is done, all scripts (provided by modules or yourself) will be deferred. This is great for performance because all scripts become non blocking and load order is preserved. Scripts are added in the head, since they are not blocking, the browser can load them while parsing the html.

Inline scripts

Deferring inline scripts is not possible as such. But since events are fired once the dom is parsed, you can wrap your scripts like so

This module automatically does this. Be aware that if you rely on global variables, you might want to prevent this from happening by adding a comment with //window.addEventListener somewhere. This will prevent our class to automatically wrap your script.

Css order

This module also check your css files and make sure your themes files are loaded last. This make sure that your styles cascade properly.

Themed javascript

You can pass an array of options instead of just "type" parameter.

Cookie consent

In order to support my cookieconsent module you can now pass an additionnal option "cookie-consent" to your javascript files to load them conditionnaly.

This also work (kind of) for custom scripts. Since the requirements api does not support anything outside script and uniquenessID, we append the cookie type to the uniquenessID id

Security headers

As a small bonus, this module allows you to add two security headers:

Js modules support

If you want to use native js modules, this can be done with the following config flag:`

Js modules are deferred by default as well. In addition, script with type=module are only loaded by modern browser, which can be really nice if you want to use modern browsers and let other older browsers experience a js-less webpage.

This allows you to use native es6 syntax without bundlers like webpack, etc. at the cost of not supporting older browsers.

Content security policy

This module also add random nonce to your scripts. This allows you to setup a simple Content Security Policy.

Also, a $getCspNonce is made available in your templates.

Please note that the csp is disabled by default. You might want to enable it with the following config:

Consider setting this to csp_report_only at the beginnning because enabling csp can break your website.

Compatibility

Tested with ^4.10

Maintainer

LeKoala - [email protected]


All versions of silverstripe-defer-backend with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8
silverstripe/recipe-plugin Version ^1 || ^2
silverstripe/vendor-plugin Version ^1 || ^2
silverstripe/framework Version ^4.4 || ^5
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 lekoala/silverstripe-defer-backend contains the following files

Loading the files please wait ....