Answer the question
In order to leave comments, you need to log in
How to merge and compress a bunch of js and css files in smarty?
In general, the problem is the following.
More than 50 js/css are included in the smarty template. It is clear that it is not reasonable to connect fifty files.
Are there ready-made solutions for combining all this goodness? The Bender class is provided just for this, but it just doesn't run for me. It turns out too clumsy and non-working js/css.
Tried minify , it doesn't digest my get requests (too long). You can create several queries, but still you want to combine everything connected into a heap. At what, ideally, with caching and by combining JS + CSS (technically this is possible and, I hope, has already been implemented by someone).
those. something like a php function, which is passed an array with a list of files to merge into one heap.
Thanks
Answer the question
In order to leave comments, you need to log in
Are you sure you need an additional library? Maybe it's better to write a function yourself that will merge an array of files into one?
Libraries, by the way, are Googled in no time at the request "php minify css/js".
Download
the plugin Place the plugin in the /smarty/plugins folder
Connect the compression classes
+ you need to correct the paths, they may be different for you
Compress styles
{compress
mode = 'css'
type = 'inline'
file = '/css/compress.css' // если не указать файл то запишет в папку кеша, путь к ней в плагине
media = 'all'
source = [
[ file => 'http://fonts.googleapis.com/css?family=Titillium+Web:300|Roboto:400,300,700,500&subset=latin,cyrillic' ],
[ file => '/css/cart.css', allow => '/cart' ],
[ file => '/css/main.css', disallow => '/cart' ],
[ file => '/css/modal.css' ]
]
}
{compress
attr = 'data-no-instant async'
mode = 'js'
type = 'include'
media = 'all'
file = '/js/compress.js'
source = [
[ 'file' => '/js/instantclick.min.js' ],
[ 'file' => '/js/jquery.js' ],
[ 'file' => '/js/modal.js' ],
[ 'file' => '/js/cart.js' ],
[ 'file' => '/js/mask.js' ],
[ 'file' => '/js/app.js' ]
]
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question