PHP code example of wp-performance / presswind-assets

1. Go to this page and download the library: Download wp-performance/presswind-assets library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wp-performance / presswind-assets example snippets


use PressWind\PWVite;

// use with named parameters for more readability

// in theme
// 1 - search dist folder in root theme
PWVite::init(port: 3000, path: '');

// 2 - search admin/dist folder in root theme
PWVite::init(port: 4444, path: 'admin', position: 'admin', is_ts: false);

// in plugin

// 3 - search dist folder in plugin test-plugin (from index.php root plugin)
PWVite::init( port: 7777, path: 'test-plugin/', plugin_path: __FILE__, slug:
'plugin-test' );


PWVite::init()->setPreloadFont();

use PressWind\PWAssets;

// for css
PWAsset::add('my-css', get_template_directory_uri().'/assets/style.css')->dependencies([])->media('all')->version('1.0.0')->toFront();
PWAsset::add('my-css', get_template_directory_uri().'/assets/style.css')->dependencies([])->media('all')->version('1.0.0')->toBack();
PWAsset::add('my-css', get_template_directory_uri().'/assets/style.css')->dependencies([])->media('all')->version('1.0.0')->toBlock();
PWAsset::add('my-css', get_template_directory_uri().'/assets/style.css')->dependencies([])->media('all')->version('1.0.0')->toLogin();


// for js
PWAsset::add('my-js', get_template_directory_uri().'/assets/js/app.js')
    ->dependencies(['jquery'])
    ->version('1.0.0')
    ->module()
    ->toFront()
    ->withInline('console.log("hello world")');

PWAsset::add('my-js', get_template_directory_uri().'/assets/js/app.js')
    ->dependencies(['jquery'])
    ->version('1.0.0')
    ->noModule()
    ->toFront();

PWAsset::add('my-js', get_template_directory_uri().'/assets/js/app.js')
    ->dependencies(['jquery'])
    ->version('1.0.0')
    ->async()
    ->inFooter()
    ->toFront();

PWAsset::add('my-js', get_template_directory_uri().'/assets/js/app.js')
    ->dependencies(['jquery'])
    ->version('1.0.0')
    ->defer()
    ->inFooter()
    ->toFront();

PWAsset::add('my-js', get_template_directory_uri().'/assets/js/app.js')
    ->dependencies(['jquery'])
    ->version('1.0.0')
    ->defer()
    ->inFooter()
    ->toBack();

PWAsset::add('my-js', get_template_directory_uri().'/assets/js/app.js')
    ->dependencies(['jquery'])
    ->version('1.0.0')
    ->defer()
    ->inFooter()
    ->toBlock();