Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wpscholar/wp-async-defer-scripts

A Composer library for asynchronously loading or deferring scripts in WordPress.
https://github.com/wpscholar/wp-async-defer-scripts

deferring-scripts wordpress wordpress-development wordpress-php-library

Last synced: about 1 month ago
JSON representation

A Composer library for asynchronously loading or deferring scripts in WordPress.

Awesome Lists containing this project

README

        

# WordPress Async/Defer Scripts

A Composer library for asynchronously loading or deferring scripts in WordPress.

## Requirements

- PHP 5.3+
- WordPress 4.2+

## Installation

Add the module to your code base via Composer

```
composer require wpscholar/wp-async-defer-scripts
```

Be sure to require the Composer autoloader in your project

```php
add_data( 'recaptcha', 'async', true );
} );
```

How to defer loading of a script:
```php
add_data( 'recaptcha', 'defer', true );
} );
```

## Initialization

In most cases, you can simply follow the installation instructions and things will just work. However, if you are including this library outside of a WordPress plugin or theme, you may have to manually initialize the class:

```php