https://github.com/themeplate/resource
Helper for resource hinting
https://github.com/themeplate/resource
directives wordpress wordpress-dependencies
Last synced: about 2 months ago
JSON representation
Helper for resource hinting
- Host: GitHub
- URL: https://github.com/themeplate/resource
- Owner: ThemePlate
- License: gpl-3.0
- Created: 2020-09-26T05:54:10.000Z (over 4 years ago)
- Default Branch: develop
- Last Pushed: 2025-03-01T05:34:38.000Z (3 months ago)
- Last Synced: 2025-03-01T06:24:31.755Z (3 months ago)
- Topics: directives, wordpress, wordpress-dependencies
- Language: PHP
- Homepage:
- Size: 39.1 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ThemePlate Resource
## Usage
```php
use ThemePlate\Resource;add_action( 'wp_head', array( Resource::class, 'action' ), 2 );
Resource::hint( 'dns-prefetch', '//cdnjs.cloudflare.com' );
Resource::hint( 'preconnect', '//ajax.cloudflare.com' );
Resource::hint( 'prerender', 'http://my.site/blog' );
Resource::hint( 'prefetch', 'jquery-migrate' );
Resource::hint( 'preload', 'jquery-core' );Resource::hint( 'preload', array(
'href' => 'https://fonts.gstatic.com/s/montserrat/v14/JTURjIg1_i6t8kCHKm45_cJD3gTD_u50.woff2',
'as' => 'font',
'type' => 'font/woff2',
) );
```### Resource::hint( $directive, $resource )
- **$directive** *(string)(Required)* Type of directive to use
- **$resource** *(mixed)(Required)*
> - URL *(string)*
> - `dns-prefetch`
> - `preconnect`
> - `prerender`
> - Handle *(string)*
> - `prefetch`
> - `preload`
> - Custom *(array)*
> - `prefetch`
> - `preload`