Giter Club home page Giter Club logo

minify's Introduction

Minify

Latest Stable Version Total Downloads License

With this package you can minify your existing stylessheet and javascript files within your Laravel environment. This process can be a little tough, this package simplifies this process and automates it.

For older Laravel versions, please use ceesvanegmond/minify or DevFactoryCH/minify.

Installation

Begin by installing this package through Composer.

{
    "require": {
    	"PerryvanderMeer/minify": "1.*"
    }
}

Or use composer require perryvandermeer/minify

Laravel installation

Then register the service provider and Facade by opening config/app.php

PerryvanderMeer\Minify\MinifyServiceProvider::class,

'Minify' => PerryvanderMeer\Minify\Facades\Minify::class,

Publish the config file:

php artisan vendor:publish --tag=minify

When you've added the MinifyServiceProvider, an extra Minify facade is available. You can use this Facade anywhere in your application

Stylesheet

// app/views/hello.blade.php

# Minify one file
{!! Minify::stylesheet('/css/main.css') !!}

# Minify multiple files
{!! Minify::stylesheet(['/css/main.css', '/css/bootstrap.css']) !!}

# Add custom attributes to the HTML element
{!! Minify::stylesheet(['/css/main.css', '/css/bootstrap.css'], ['foo' => 'bar']) !!}

# Add the full resource URL to the HTML element
{!! Minify::stylesheet(['/css/main.css', '/css/bootstrap.css'])->withFullUrl() !!}

# Load an external resource
{!! Minify::stylesheet('//fonts.googleapis.com/css?family=Roboto') !!}

# Minify and combine all files in a given folder
{!! Minify::stylesheetDir('/css/') !!}

# Add custom attributes to the HTML element
{!! Minify::stylesheetDir('/css/', ['foo' => 'bar']) !!}

# Add the full resource URL to the HTML element
{!! Minify::stylesheetDir('/css/', ['foo' => 'bar'])->withFullUrl() !!}

Javascript

// app/views/hello.blade.php

# Minify one file
{!! Minify::javascript('/js/jquery.js') !!}

# Minify multiple files
{!! Minify::javascript(['/js/jquery.js', '/js/jquery-ui.js']) !!}

# Add custom attributes to the HTML element
{!! Minify::javascript(['/js/jquery.js', '/js/jquery-ui.js'], ['foo' => 'bar']) !!}

# Add the full resource URL to the HTML element
{!! Minify::javascript(['/js/jquery.js', '/js/jquery-ui.js'], ['foo' => 'bar'])->withFullUrl() !!}

# Load an external resource
{!! Minify::javascript('//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js') !!}

# Minify and combine all files in a given folder
{!! Minify::javascriptDir('/js/') !!}

# Add custom attributes to the HTML element
{!! Minify::javascriptDir('/js/', ['foo' => 'bar']) !!}

# Add the full resource URL to the HTML element
{!! Minify::javascriptDir('/js/', ['foo' => 'bar'])->withFullUrl() !!}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.