I have the following code that checks for all scripts with .js and compresses them.
if (preg_match('/\.js$/i', $script)) {
$asset = $this['asset']->createFile($script);
if ($asset->getPath()) {
$script = $this['asset']->cache(basename($script), $asset, array('JsCompressor'), $options)->getUrl();
}
}
Here's a sample of JS files it's searching through:
media/j2store/js/j2store.namespace.js
media/j2store/js/j2store.js
media/j2store/js/jquery-ui.min.js
media/j2store/js/jquery-ui-timepicker-addon.js
media/j2store/js/jquery.zoom.js
There's one js file I want it to omit i.e. j2store.js. I've tried using the negative lookahead but it doesn't work.
if (preg_match('/(?!j2store)\.js$/i', $script)) {
$asset = $this['asset']->createFile($script);
if ($asset->getPath()) {
$script = $this['asset']->cache(basename($script), $asset, array('JsCompressor'), $options)->getUrl();
}
}
Your help will be greatly appreciated.