gavinggordon/assetinc

A PHP class which provides simple javascript or css asset inclusion.

1.0.1 2016-04-08 14:55 UTC

This package is not auto-updated.

Last update: 2024-04-13 16:24:02 UTC


README

Build Status

This class (GGG\AssetInc\AssetInc) provides a simple and quick way to include/add JS or CSS assets to an HTML document's head and/or body.

Installation

composer require gavinggordon/assetinc

Examples

Instantiation:

include_once( __DIR__ . '/vendor/autoload.php' );

$JSasset = \GGG\AssetInc\AssetInc::init( 'js' );

$CSSasset = \GGG\AssetInc\AssetInc::init( 'css' );

JS:

$JSasset->insert( 'jquery' );
// Result: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>

$JSasset->add_asset( ASSET_NAME, ASSET_URL );
$JSasset->insert( ASSET_NAME );
// Result: ASSET_URL

CSS:

$CSSasset->insert( 'font-awesome' );
// Result: <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet">

$CSSasset->add_asset( ASSET_NAME, ASSET_URL );
$CSSasset->insert( ASSET_NAME );
// Result: ASSET_URL

View this class package on PHPClasses.org.