Skip to content

A PHP package for minifying your .css and .js.

License

Notifications You must be signed in to change notification settings

nickdekruijk/minify1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minify

Since the original DevFactoryCH/minify seems to be inactive I've forked it and added Laravel 5.5 autodiscovery so it's much simpler to use.

Installation

Begin by installing this package through Composer.

composer require nickdekruijk/minify

Laravel installation

Publish the config file:

php artisan vendor:publish --provider="NickDeKruijk\Minify\MinifyServiceProvider"

Stylesheet

// app/views/hello.blade.php
<html>
	<head>
		...
		{!! Minify::stylesheet('/css/main.css') !!}
		// or by passing multiple files
		{!! Minify::stylesheet(['/css/main.css', '/css/bootstrap.css']) !!}
		// add custom attributes
		{!! Minify::stylesheet(['/css/main.css', '/css/bootstrap.css'], ['foo' => 'bar']) !!}
		// add full uri of the resource
		{!! Minify::stylesheet(['/css/main.css', '/css/bootstrap.css'])->withFullUrl() !!}
		{!! Minify::stylesheet(['//fonts.googleapis.com/css?family=Roboto']) !!}

		// minify and combine all stylesheet files in given folder
		{!! Minify::stylesheetDir('/css/') !!}
		// add custom attributes to minify and combine all stylesheet files in given folder
		{!! Minify::stylesheetDir('/css/', ['foo' => 'bar', 'defer' => true]) !!}
		// minify and combine all stylesheet files in given folder with full uri
		{!! Minify::stylesheetDir('/css/')->withFullUrl() !!}
	</head>
	...
</html>

Javascript

// app/views/hello.blade.php

<html>
	<body>
	...
	</body>
	{!! Minify::javascript('/js/jquery.js') !!}
	// or by passing multiple files
	{!! Minify::javascript(['/js/jquery.js', '/js/jquery-ui.js']) !!}
	// Combine some javascripts from composer packages
        {!! Minify::javascript(['/../vendor/components/jquery/jquery.js', '/../vendor/nickdekruijk/slider.js/slider.js', '/js/scripts.js']) !!}
	// add custom attributes
	{!! Minify::javascript(['/js/jquery.js', '/js/jquery-ui.js'], ['bar' => 'baz']) !!}
	// add full uri of the resource
	{!! Minify::javascript(['/js/jquery.js', '/js/jquery-ui.js'])->withFullUrl() !!}
        {!! Minify::javascript(['//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js']) !!}

	// minify and combine all javascript files in given folder
	{!! Minify::javascriptDir('/js/') !!}
	// add custom attributes to minify and combine all javascript files in given folder
	{!! Minify::javascriptDir('/js/', ['bar' => 'baz', 'async' => true]) !!}
	// minify and combine all javascript files in given folder with full uri
	{!! Minify::javascriptDir('/js/')->withFullUrl() !!}
</html>

Config

See the config file at /config/minify.php

About

A PHP package for minifying your .css and .js.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%