forked from bennettstone/magic-min
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
126 lines (103 loc) · 3.68 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
/**
* example.php
*
* Demonstrates compression functions and minification usage
* for stylesheets and javascript files
*
* @author Bennett Stone
* @version 2.5
* @date 02-Jun-2013
* @updated 15-Jun-2013
* @package MagicMin
**/
//Include the caching/minification class
require( 'class.magic-min.php' );
//Initialize the class with image encoding, gzip, a timer, and use the google closure API
$vars = array(
'encode' => true,
'timer' => true,
'gzip' => true,
'closure' => true
);
$minified = new Minifier( $vars );
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lang="EN" dir="ltr">
<head profile="http://gmpg.org/xfn/11">
<title>Example Usage | Caching and Minification Class</title>
<?php
/*
<!--Output a new merged stylesheet with only the $included_styles included in order-->
<?php
$included_styles = array(
'css/bootstrap.css',
'https://raw.github.com/zurb/reveal/master/reveal.css',
'css/base/jquery-ui.css'
);
?>
<link rel="stylesheet" href="<?php $minified->merge( 'css/awesome.min.css', 'css', $included_styles ); ?>" />
<!--Output a default minified stylesheet: will output as css/bootstrap.min.css-->
<link rel="stylesheet" href="<?php $minified->minify( 'css/bootstrap.css' ); ?>" />
<!--Output a minified javascript file with completely different name, and ?v=1.8 param-->
<script src="<?php $minified->minify( 'js/jquery.reveal.js', 'js/jquery-magicreveal.min.js', '1.8' ); ?>"></script>
<!--Retrieve the contents of all javascript files in the /js directory as master.min.js (excluding a couple AND making sure bootstrap and validate are first and second)-->
<?php
$exclude = array(
'js/autogrow.js',
'js/jquery.reveal.js'
);
$prioritize = array(
'js/bootstrap.js',
'js/jquery.validate.js'
);
?>
<script src="<?php $minified->merge( 'js/packed.min.js', 'js', 'js', $exclude, $prioritize ); ?>"></script>
<!--Get all the stylesheets in a directory and make a single minified stylesheet (excluding the ones used above)-->
<?php
$exclude_styles = array(
'css/bootstrap.css',
'css/bootstrap.min.css'
);
?>
<link rel="stylesheet" href="<?php $minified->merge( 'css/master.min.css', 'css', 'css', $exclude_styles ); ?>" />
<!--Get all the stylesheets in the /base directory and compile them-->
<link rel="stylesheet" href="<?php $minified->merge( 'css/base/bennett-min.css', 'css/base', 'css' ); ?>" />
<!--Include ONLY a specified list of files IN ORDER-->
<?php
$include_only = array(
'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js',
'http://code.jquery.com/jquery-migrate-1.2.1.min.js',
'js/autogrow.js',
'js/jquery.reveal.js',
'js/bootstrap.js'
);
?>
<script src="<?php $minified->merge( 'js/compressor.min.js', 'js', $include_only ); ?>"></script>
*/
?>
</head>
<body>
<h1>TESTFILE</h1>
<a href="#" class="new-modal">Click Me For A Modal</a>
<div id="myModal" class="reveal-modal">
<h1>Modal Title</h1>
<p>Any content could go in here.</p>
<a class="close-reveal-modal">×</a>
</div>
<textarea name="whatever"></textarea>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('textarea').TextAreaExpander(100);
$('.new-modal').click(function(e) {
e.preventDefault();
$('#myModal').reveal();
});
});
</script>
<?php
//Output actions associated with the minification to the console
$minified->logs();
?>
</body>
</html>