Miser - Web site OptiMISER

Permalink 16 users found helpful
Since a new, (completely unrelated) "Concrete On Steroids" thread has recently started. I thought I would take the opportunity to remove confusion whilst making it easier for people to find the code and updates - lets face it, with over 300 posts, the original thread was a nightmare!

The original "Concrete On Steroids" (the birth-place of MISER) may be found here:
http://www.concrete5.org/community/forums/chat/concrete-on-steroids...

The latest versions of MISER can always be found here:
http://sourceforge.net/projects/miser/...

WHAT IS MISER?

MISER (a play on words combining the latter part of optmiser and a the word to mean a hoarder of assets) is a PHP module designed to automatically implement website best practices to streamline browser responsiveness and improve end-user perceived performance.

It is designed to be a maintenance-free "bolt-on" helper that analyses and restructures a pages output to the browser to implement best pratices for page optimisation. MISER enables minification of javascript and CSS on-the-fly, combining javascript and CSS into single files to reduce HTTP requests as well as sorting and placing links at the end of the body section so as not to impact page rendering.

It was born out of a need to improve a Concrete5 web sites performance and responsiveness since the vanilla concrete5 seemed slow and sluggish. Indeed, the Concrete5 community was the proving ground, but it is grown to be more general and can be applied to any web site now that it is mature, well tested and shown to improve the user experience. However, Concrete5 will always be the main focus for support and features.

Unlike many other combiners and minifiers, MISER does not require constant management when new pages, CSS or Javascript are added. It detects any changes to your site and creates any required files. It also has a few other tricks up it's sleeve such as replacing local links (like jquery) with CDN hosted files and being able to move Google Analytics and Javascript to the top or bottom of the page.

MISER has been tested on many real Concrete5 sites and is proven to be compatible with many "Market Place" addons straight out of the box or with slight configuration changes.

Key Features:
-Javascript minification.
-CSS minification.
-HTML minification.
-Javascript combining.
-CSS combining.
-Content Delivery Network (CDN) support.
-Header sorting (CSS and Javascript).
-Analytics placement (header or end of the body section).
-Javascript placement (header or end of the body section).
-EU Cookie directive compliance.

Requirements:
PHP 5.2.5 or greater (compiled with PCRE 7.2 or later)
Concrete 5.4.1 - 5.6.x

Licensing : Creative Commons (CC BY-NC-SA 3.0)
http://creativecommons.org/licenses/by-nc-sa/3.0/...
If you are not sure. Just PM me and ask!

Phallanx
 
rckDsgn replied on at Permalink Reply
rckDsgn
Hi Phallanx,

I have a shared hosting account from Strato.com and I can only get Miser working in a website which resides in the root directory of the hosting account.
When I try to use it in a domain which is hosted from a subdirectory it places the 'files/cache' directory in the root directory above, which results in a broken link to the css and js files. I've searched through the Miser thread and the C5 site but can't find a solution. Is there a setting where I can define the location of the cache directory?

Additional info: the hosting package does not give me access to the directories above the root directory (htdocs) of my hosting package. Htaccess and ini files are possible.

Rick
Phallanx replied on at Permalink Reply
Phallanx
The Concrete5 specific settings are all in miser_bridge_C5.php in the "miser_support" directory.

At the top of that file you will see
// Cache directories
$this->css_dir( REL_DIR_FILES_CACHE.'/css/' );
$this->js_dir ( REL_DIR_FILES_CACHE.'/js/' );


You will notice that it prepends "REL_DIR_FILES_CACHE" which is a CC5 define so it should place the files in the same place as the CC5 cache regardless of where the installation is. For it to deposit them into css and js off the root (when you are actually in a subdirectory), this define must be empty for some reason.

Regardless. This is where you can change the directory that Miser puts the cache files into.
rckDsgn replied on at Permalink Reply
rckDsgn
In my /config/site.php I've got the following:
define('BASE_URL', 'http://www.rckdsgn.nl');
define('DIR_REL', '');


Is this the place where I should define a directory for REL_DIR_FILES_CACHE?

The CC5 install is running fine from within this directory and, when turned on, the regular CC5 cache files are written to the /files/cache/ directory.
Phallanx replied on at Permalink Reply
Phallanx
@rckDsgn
The define "REL_DIR_FILES_CACHE" already exists (it resides in base.php in the concrete/config/ directory). I wouldn't suggest you change anything in the core (if it's not broke, don't fix it).

Instead, I would suggest that you modify the aforementioned paths in miser_bridge_c5.php and hard code a directory that you want Miser to use.

In the meantime, I will see if I can replicate what you are seeing. I have had no other reports of problems with different installs either in the root or in sub-directories, but that doesn't mean there isn't a problem.
adamjohnson replied on at Permalink Reply
adamjohnson
FYI miser_bridge_c5 should be in (root)/helpers/miser_support/miser_bridge_C5.php.
rckDsgn replied on at Permalink Reply
rckDsgn
Tried a lot of different settings in miser_bridgec5.php without any success.
I think it has someting to do with the type of shared hosting being used on the Strato server. Maybe it's related to the php.ini file I had to use to get the pretty urls functioning:
safe_mode = off
cgi.fix_pathinfo = 0


@riotaj: installation of miser was done correctly and runs just fine from a domain in the root directory but thanks anyway.
Phallanx replied on at Permalink Reply
Phallanx
@rckDsgn
Hmmm. You say it OK on in root, but not is it is a subdirectory off of root. And is the the entry in your config for the off-root sub directory?
define('DIR_REL', '');

if it is, then what "maybe" happening is that Miser is attempting to save the files to a directory that it doesn't have permissions for
You can try
define('DIR_REL', '/MySubDir');
rckDsgn replied on at Permalink Reply
rckDsgn
@Phallanx

For future reference: a summary of the steps taken.
[ it's probably specific to Strato Shared hosting ]

In /config/site.php:
define ( 'DIR_REL','/MySubDir');

This did not work, it just appended /MySubDir to all generated links.
(replace 'MySubDir' with the real directory name)

In /helpers/miser_support/miser_bridge_C5.php:
// Cache directories ->replaced REL_DIR_FILES_CACHE with DIR_FILE_CACHE
$this->css_dir( DIR_FILES_CACHE.'/css/');
$this->js_dir( DIR_FILES_CACHE.'/js/');

This put the merged css and js files in the correct directory. The links to the js and css files in the html output, however, get printed out incorrectly. An extra /MySubDir is appended to the css and js links (all other links are correct). I think I know where it originates from, but I don't know how to fix it. In /helpers/miser.php the urls get stripped by removing the server defined root.
$_SERVER['DOCUMENT_ROOT']

This strips out everything till the root directory of the hosting package but leaves the directory from which the domain is hosted... resulting in the extra /MySubDir
Phallanx replied on at Permalink Reply
Phallanx
@rcdesign
Hmmm. The DIR_REL is not used/blank, yet concrete is somehow able to resolve paths?. Where is the sub-directory being pre-pended for file paths and how does concrete know where it (itself) is? (rhetorical questions - thinking out loud).

Although the links in the page are incorrect (the server obviously thinks the files are relative to the root) do the files generated by Miser (with the DIR_FILES_CACHE for the location) actually contain any contents? If they do, then it must means that (for your installation) the sub-directory needs to be stripped as well as "$_SERVER['DOCUMENT_ROOT']" but only for links. The question is, where is it defined that a directory off of root really means a sub-directory off root? (DIR_REL is what concrete uses, but isn't used in this case).

You'll have to bear with me on this one. The mechanism (and therefore the solution) isn't obvious to me.
rckDsgn replied on at Permalink Reply
rckDsgn
Thanks to the terriffic support Phallanx has given me through numerous emails my problem has been solved.

Just had to straighten out my htaccess file with a code snippet from the original Steroids Thread:
<IfModule mod_deflate.c>
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
<IfModule mod_expires.c>
<IfModule mod_headers.c>
Header unset Pragma


'Ouch!' I hear you thinking? Correct! It takes a noob like me to overlook this sort of thing. But hey, I've learnt something I'll probably never forget again.

For those who will be visiting The Netherlands next week: I'm the one wearing the 'Kick Me' sign ;-)

@Phallanx
Thank you for your patience with me and your great support.
Phallanx replied on at Permalink Reply
Phallanx
@rckDsgn
I think you spoke too soon...lol.
The .htaccess mod doesn't really have anything to do with miser. It's all about the server making content more attractive to browsers and remote caches for off-site caching.

The real fix was to add the following to miser_bridge_c5.php.
$this->set_root(DIR_BASE);


The problem arose from setting "cgi.fix_pathinfo=0" in the php.ini file AND CC5 being in a sub-directory off of root AND the domain pointing straight to the directory. The cgi switch was introduced since CC5 pretty urls wouldn't work without it. This caused there to be a disparity between the DOCUMENT_ROOT and the base url which Miser could not tell existed. The effect was that Miser would try to place it's cache files in the "DOCUMENT_ROOT/files/cache" rather than "DOCUMENT_ROOT/SUB-DIRECTORY/files/cache"

My thanks to you, rckDsgn, for bearing with me on this one as although the solution was simple, what was happening was not obvious and took a while to track down.
DominicWhiteStudio replied on at Permalink Reply
DominicWhiteStudio
Hi Phallanx,
Thanks for all your hard work on this. The file html.php was not bundled with the Miser 1.5.0 I downloaded off of sourceforge, and i could not find it on the google code repository. Is there a direct link to it?
Appreciate it and can't wait to test this out!
Phallanx replied on at Permalink Reply
Phallanx
@DominicWhiteStudio
html.php? Why are you looking for that? It is part of the concrete core and is located in /concrete/helpers
DominicWhiteStudio replied on at Permalink Reply
DominicWhiteStudio
This was in the Installation instructions of the Miser Readme.txt...

2) INSTALLING MISER

MISER requires "jsmin.php" and "html.php" in order to minify Javascript and
HTML. In the unlikely event that they are not bundled with this zip
file they can be downloaded from the google code repository.

jsmin.php was in the support folder and html.php was not, hence my confusion.
Phallanx replied on at Permalink Reply
Phallanx
@DominicWhiteStudi
Aha. My apologies and my thanks for pointing that out. That is a mistake in the documentation left over from Misers original incarnations. The html.php it is referring to is "minify_HTML.php" I had to rename the authors original file since the CC5 core uses the same name. It is included in the zip file. I will update the documentation on the next release.

As a point of note. If any of the 3rd party files (e.g jsmin, minify_html.php) are not present. Miser will still work, it just won't enable those features.
okapi replied on at Permalink Reply
okapi
For those, who didn't yet follow the link to the creative commons CC BY-NC-SA 3.0 license:

This license does NOT allow using this software for commercial websites!

You cannot even buy a license to use miser for commercial websites. It depends solely on the goodwill (!) of the author if he likes to allow you to use it for commercial websites.

This very restrictive license does not fit the concrete5 philosophy and of course not it's license model. That's the reason, why miser will never find it's way to the marketplace as an add-on, not even as a free one.

Michael
rckDsgn replied on at Permalink Reply
rckDsgn
@okapi

Although I can understand your point regarding the inability to put it in the marketplace, there's nothing wrong with just asking the author politely (I did) if you can use the software on your site. As I recall Phallanx stated clearly he had the hope that it could lead to the development of a similar addition toCC5 by either the Core Team or someone else.
And that is exactly what is happening right now, looking at the latest discussions...
hereNT replied on at Permalink Reply
hereNT
I was about to install this on multiple client sites at our development shop until I saw this, sad that such great work can't actually be used.
zoinks replied on at Permalink Reply
Uh... what? I have been using it on a few sites and seemingly with Phallanx's full permission as he helped answer some questions and stuff. I guess I have to remove Miser? Phallanx? Can you spell it out for me here? Do you want payment or what? I want to use Miser legally and thought I was. thanks.
Phallanx replied on at Permalink Reply
Phallanx
@zoinks
Miser is Creative Commons (CC BY-NC-SA 3.0). If you want to make make money off it; you cannot without my permission. It is discussed at length in the Concrete On Steroids thread (links are at top of this page).
hereNT replied on at Permalink Reply
hereNT
I wasn't going to resell it to our clients, I merely wanted to install it and use it on sites that are commercial in nature and that we've already created / charged for the coding for. Would that be allowable?
zoinks replied on at Permalink Reply
^ this is what I was doing; just added it to sites as a performance boost at no additional charge (or even mention) because the C5 site was so damn slow. I apologize if this is not allowed; the original threads were so damn long and everyone was high-fiving you about Miser, so I thought it was naturally to be used freely. I can't imagine people would be thrilled over you letting them make their personal sites go faster. Who could possibly care about the speed of a non-profit C5 blog (or whatever)? Just use Wordpress. I think people are not using your product how you intend if you do not intend for people to boost commercial sites with your product because most certainly that is why everyone is so happy. We are not making a living off personal sites here.
zoinks replied on at Permalink Reply
Actually, I think this quote from Phallanx answers the question:
---------------
The full licence (Creative commons is layered to enable easy reading) is here
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode......

The section you are probably interested in is 4.c which states:

"You may not exercise any of the rights granted to You in Section 3 above in any manner that is primarily intended for or directed toward commercial advantage or private monetary compensation."

So corporations can use it. They just cannot charge for the product if they do - they have to share also (without asking for a waiver - they can of course ask for one).
-----------------

Key phrase is: "So corporations can use it. They just cannot charge for the product if they do" ...which I'm sure I must have read before choosing to use Miser. I don't charge for Miser.
jordanlev replied on at Permalink Reply
jordanlev
Well, I'm not a lawyer and I'm not Phallanx, but my understanding of his *intentions* are as follows:
Use MISER for free if the site is for personal use or for a non-profit organization. If the website is used directly to make a profit (you sell things on it or charge a subscription for access to it) OR it is a website that supports, markets, or is generally "for" a for-profit company, then you need to pay Phallanx for a waiver to the license for that particular site.

I have no idea if the actual licenses or legalese would support this in a court of law or whatever, but as a developer myself I understand how much time and effort is involved in creating great software, so I want to support other developers who are in the same boat -- so I personally choose to do whatever it is Phallanx wants people to do with his software, even if technically one could find some loophole in the contract.

Perhaps he could do a better job of more clearly explaining the process (although my reading of the various "Concrete On Steroids" threads seemed pretty clear to me), but this is all just my take on things. Obviously Phallanx is the final word here.
Phallanx replied on at Permalink Reply
Phallanx
@hereNT
The licence prohibits the commercial "USE", not the distribution (that is share-alike). If your clients want to use it on a commercial site; they have to obtain a commercial waiver for that site. Email me (address in the readme of the Miser zip package or at the top of Miser.php) if you have sites that you think may require a commercial waiver.

As a general rule. A waiver is not required for NPOs, schools, charities and personal/family websites.
jordanlev replied on at Permalink Reply
jordanlev
You can in fact use MISER on commercial sites -- you just need to purchase a license from @Phallanx. I have done so in the past (and will continue to do so in the future when needed) and am incredibly happy with both the functionality of MISER and @Phallanx's responsive support. Just send him a PM and I'm sure he'd be happy to get you the licenses you need :)

-Jordan
zoinks replied on at Permalink Reply
Alrighty then... how can I purchase a license or 3?
jordanlev replied on at Permalink Reply
jordanlev
Contact @Phallanx and ask -- click his username in the forums here which will bring you to his profile page, and there should be a button over to the right that says "Send Message".
ceyhuncenger replied on at Permalink Reply
ceyhuncenger
I did exactly what is written in the read me file section 2a, but the header and the footer of my site were gone away. I am using 5.4.1.1 and theme officespace which is under packages folder. The header and the footer are located inside the that officespace theme under elements folder.
Then I tried to put those 2 footer.php and header.php files in the root/elements folder, but did not make any difference.
What do you think I am doing wrong?
Phallanx replied on at Permalink Reply
Phallanx
@ceyhuncenger
I cannot try the OfficeSpace theme since it is a paid addon. But paste or PM a link to your website and I will see if I can guess what is happening.

I use a theme that has header and footer elements, so it shouldn't be an issue.
ceyhuncenger replied on at Permalink Reply
ceyhuncenger
I sent you the link. Have you looked at it, yet? I cannot keep the website like this for long time.
Thanks,
Ceyhun
ceyhuncenger replied on at Permalink Reply
ceyhuncenger
The browser views it with print.css instead of main.css
Phallanx replied on at Permalink Reply
Phallanx
OK.
Your superfish menu is being added before jquery so it looks like Miser cannot re-organise it for some reason. Generally the superfish javascript is replaced with a CDN, but it looks like it's a slightly different name from the one Miser expects.

The simplest solution is to add this line to your site.php (located in <root>/config/)
define( 'MISER_KEYS_HEAD', array('jquery.js'));
ceyhuncenger replied on at Permalink Reply
ceyhuncenger
Ok, thanks a lot.
Phallanx replied on at Permalink Reply
Phallanx
Miser 1.6.0 has just been released as of 31/05/2011

The update includes some minor fixes and improvements.

The main change is that Miser is now capable of removing Google Analytics completely from the page and restore it when a cookie has been set. This is to assist in EU compliance to the new directives requiring permission for cookies to be placed on an end-users machine which came into force on the 26th of May 2011.
Phallanx replied on at Permalink Reply
Phallanx
Miser 1.6.1 has been released as of 02/06/2011.

This is a bug-fix release specifically to address warnings being issued when displaying non-html pages (e.g. RSS feeds, atom feeds etc) when in not in production mode. This bug was introduced in 1.6.0 (sorry about that-it was tested, honest) and does not affect previous versions.
TheRealSean replied on at Permalink Reply
TheRealSean
Some Great Results, when testing it out on one of my older sites.

Before
33 requests ā˜ 210.31KB transferred ā˜ 1.28s (onload: 1.28s, DOMContentLoaded: 855ms)

Without Htaccess mods,
28 requests ā˜ 158.74KB transferred ā˜ 923ms (onload: 923ms, DOMContentLoaded: 732ms)

After Miser With Htaccess Mods
28 requests ā˜ 139.18KB transferred ā˜ 893ms (onload: 896ms, DOMContentLoaded: 628ms)

Some Pages where taking upwards of 4 seconds to load with Miser now each page is less then 1 second.

Great work Phallanx
Phallanx replied on at Permalink Reply
Phallanx
@Seanom
Huh? Doesn't seem much in it from those figures.

Miser can take a while on the first ever page load since it has to combine and minify. After that it is cached. If you are doing a lot of editing of CSS and/or JS then it will do it every time, so it's better to turn it off for that and turn it back on again after.
TheRealSean replied on at Permalink Reply
TheRealSean
Hmm I was having trouble finding a long page load that would track in the inspector, maybe cache issues? as I took these figures after adding miser then removing it. I did try to clear the cache.

Anyway needless to say miser really seems to speed up the site there is a noticeable difference browsing with it turned on.
Phallanx replied on at Permalink Reply
Phallanx
@Details (Or should that be Seanom...lol)
I recommend turning the cache off and clearing it completely. You don't need it anymore and on occasion will bypass Miser (maybe that is the reason for your sometimes slow page loads). Also, Miser with cache enabled seems slower.

Miser doesn't use the CC5 cache at all. It uses a very simple (but effective) caching system by just saving all the minified files on the first ever page load and then afterwards just replacing the link in the page. This means that it gets the 304 not-modified and doesn't override htaccess configurations-much better for off-site/browser caches. So it might take 4 seconds the first time you change CSS or Javascript in the page, but after it's usually very quick (~0.02 seconds).
zoinks replied on at Permalink Reply
So... how does one install miser?

I downloaded the zip, but no instructions on these first posts...

...all subsequent posts seem to be by people who figured out how to install it, at least.
Adreco replied on at Permalink Reply
Adreco
Once you unzip the file, there's a read-me file inside with very easy install instructions
zoinks replied on at Permalink Reply
LOL... thanks. I'm not sure why that never occured to me. I guess I'm used to readme.txt files being a buncha irrelevant blather.
zoinks replied on at Permalink Reply
YOWZA YOWZA YOWZA, this is so simple and improved the speed of 2 sites TREMENDOUSLY!

Thank you, OP. You are proof that there are still good people in the world. Frank Zappa would be proud of your license stance, too... that is a compliment; FZ is my hero. :)
Phallanx replied on at Permalink Reply
Phallanx
@Zoinks.
So I guess you see the point now...lol.
zoinks replied on at Permalink Reply
Yeah, I was confused by all the responses, which gave me the impression that this was a really complicated and troublesome thing surely not worth it. The truth is you take two files and ya stick 'em in one folder, then you take another file and stick it in one other folder. Then, you disable C5's caching in the dashboard. Then it works no problem.

LOL

Well, I have had some strange things happen, but I don't know if they are related to miser or not. I had an auto-nav putting circles for the list-style-type which it grabbed from the browser. I thought maybe this might be miser-related since Miser stacks all your CSS in some faster-loading way which maybe somehow did something (???). I fixed it by adding one line of what should be unnecessary style to my CSS to override the browser style.
Phallanx replied on at Permalink Reply
Phallanx
The CDN for the modenizer javascript has changed since the last release.

If you are using it please find the "miser_CDNS.php" in the "miser_support" directory and replace on line 46
$this->Add('modernizr',            'FOOT',2,   'ajax.cdnjs.com/ajax/libs/modernizr/1.7/modernizr-1.7.min.js');

with
$this->Add('modernizr',            'FOOT',2,   'cdnjs.cloudflare.comm/ajax/libs/modernizr/1.7/modernizr-1.7.min.js');
zoinks replied on at Permalink Reply
what will happen if we don't?
adamjohnson replied on at Permalink Reply
adamjohnson
Nothing at the moment. The CDN link from cdnjs.com still works (you can copy and paste it into your browser and see it). That said, it's likely that they will, at some point (yet to be determined), phase the CDN traffic from their A3 CDN to Cloudflare.

This change will be updated in the next version of miser.
zoinks replied on at Permalink Reply
So, if we use Miser, it will mean we will have to keep on top of it because portions of it are remote and can change without warning? I guess I need to start a list of C5 sites which use this and search this board frequently for "Miser" to see if there are any updates?
adamjohnson replied on at Permalink Reply
adamjohnson
Zoinks,

Not really. The only file that you may want to have a look at would be the miser_CDNS.php file in the /miser_support directory. That file houses the CDN's that miser will use if you have stuff like jQuery, jQ UI, jQ Tools, Modernizr, etc.

For the most part, all of these libraries are either coming from Google or cachedcommons.org (GitHub CDN). The only exception was Modernizr which recently changed to the Cloudflare CDN via cdnjs.com . In other words, all very reliable sources.

To summarize, it's basically a set-it-and-forget-it mod. Enjoy!
Phallanx replied on at Permalink Reply
Phallanx
@Riotaj
Thanks for replying in my absence.

@Zoinks.
If it really worries you, you can delete the miser_CDNS.php and it won't use any of them (it won't fall over either). But as Riotaj says. CDNS rarely change so you don't have much to worry about. That is the only one in the four months that Miser has been around and I don't expect any more to change in the next year (famous last words!)
Mnkras replied on at Permalink Reply
Mnkras
Hi Phallanx,

Im having this weird issue on 1 page on one of my sites,http://screencast.com/t/hwqlOjfgy...

stack trace:

Exception Occurred: Unterminated string literal.
#0 /httpdocs/helpers/miser_support/jsmin.php(266): JSMin->action(1)
#1 /httpdocs/helpers/miser_support/jsmin.php(64): JSMin->min()
#2 /httpdocs/helpers/miser.php(529): JSMin::minify('// cannot rely ...')
#3 /httpdocs/helpers/miser.php(400): MiserHelper->write_js(Array, '??ccm_menuObj57...')
#4 /httpdocs/helpers/miser.php(85): MiserHelper->do_optimise('<!DOCTYPE html>...')
#5 /httpdocs/libraries/view.php(782): MiserHelper->optimise('<!DOCTYPE html>...')
#6 /httpdocs/concrete/dispatcher.php(245): View->render(Object(Page))
#7 /httpdocs/index.php(2): require('/httpdocs/concrete...')
#8 {main}


I have even deleted the page and it still does it,
Phallanx replied on at Permalink Reply
Phallanx
Hi Mnkras.
Does the problem go away if you delete the jsmin.php? (Clear out your js and css in the cache directories first).

Miser should detect that jsmin is missing and not use it.
Mnkras replied on at Permalink Reply
Mnkras
I ended up removing the entire page, so I can't test it, but jsmin was working on all other pages just fine, also I had to modify the regex for an older php 5.2 install if you want it.
Phallanx replied on at Permalink Reply
Phallanx
@Mnkras.

I presume you are talking about the "?|". Sure. If you have a better regex (it makes my head hurt).
Mnkras replied on at Permalink Reply
Mnkras
//if (preg_match( '#(?|href|src)="(.+)"#iU',$item,$url )>0){ //original
if (preg_match('#\s(?:href|src)="([^"]+)"#',$item,$url)>0){
1976Ltd replied on at Permalink Reply
1976Ltd
Hi,

Have installed Miser and it seems to do a great job as it says.

I may have found a bug in Safari though. When I use Miser with all the default features my pages render correctly in Firefox but in Safari any styles which are merged (from stylesheets added by add-on modules) are missing.

It seems that Safari has a problem reading the merged css file.

I've set this is the config for now:

private $endis_css_combine = FALSE; // Enable/disable combining css into 1 file

but I'd love to get this working in Safari too.

Thanks
1976Ltd replied on at Permalink Reply
1976Ltd
Seem to have fixed it. The css not working was in the Thumbview add-on which had the following at the start of the css file:

@charset "UTF-8";
@media screen, projection
{

After removing this, it works fine in Safari as well with all Miser's defaults on.
Phallanx replied on at Permalink Reply
Phallanx
@tinsoldier.

@charset is something I've been meaning to look into. Miser is a bit dumb on that at the moment, since it should be the first in the file and appear only once. Currently, however, miser doesn't recognise it and just includes it wherever it is, so you can end up with multiple @charsets in various places throughout the file.
jeramy replied on at Permalink Reply
jeramy
First of all, I love what you've accomplished here.

I do have a quick question, and maybe I missed something browsing all of these posts.

Should I see individual js and css files been concatenated and minified into one file? I still see separate file links in the footer and the only thing that looks combined are the inline JS and CSS.

Thanks,

-J
Phallanx replied on at Permalink Reply
Phallanx
@jeramy

It depends.

Offsite javascript (like the CDNs) will be separate links and sorted near the top of the footer. Dynamic JS buried in PHP files (like the i18n_js-although that one isn't dynamic) are merely sorted to the footer. If Miser can find a file, it will attempt to combine it into the blahblah_merge.js. If it can't, then it will just append it to the rest of the links. It will also try and put the in-line JS in the file too.

There are some exceptions. tiny_mce.js, for example, hates being merged and, in fact, hates anything and anybody fiddling with it. So it just gets left alone. Similarly, with known troublemakers, Miser just sorts it rather than combines it.

Miser is designed to prefer compatibility over optimisation so if it cannot find or safely merge a file-it won't and if a particularly troublesome file is causing problems, there are plenty of settings to get Miser to work around it.
kaost replied on at Permalink Reply
Amazing. Thank you so much!!
Phallanx replied on at Permalink Reply
Phallanx
@kaost
I guess it works then? :)
kaost replied on at Permalink Reply
Works great, concrete5 on steroids is an understatement. I was almost ready to switch hosting providers, but thanks to miser, it saved me a headache.

The only problem I was running into was, when I tried to embed vanilla forums inside of a block, it loaded the embed code at the bottom of the page (beneath the footer)? Any suggestions?
Phallanx replied on at Permalink Reply
Phallanx
@kaost
You can get MISER to ignore stuff (or place it in certain places) by keywords.

In your site.php put
define( 'MISER_KEYS_IGNORE', array('KEYWORD') );

Where KEYWORD is a string that you want to ignore e.g.
define( 'MISER_KEYS_IGNORE', array('embed') );


You can also define many keywords e.g.
define( 'MISER_KEYS_IGNORE', 'embed,myJS.js,yourJS.js') );


Many (all) the defines that can be used with MISER are in the readme file.
kaost replied on at Permalink Reply
The code you gave wasn't working. So added this line of code into my site.php
define( 'MISER_KEYS_IGNORE','embedvanilla, remote.js, forum/plugins');


Does this look correct my friend? It seems to be working now, but I'm not sure if I added it correctly.
Phallanx replied on at Permalink Reply
Phallanx
@kaost
The code was an example of using the keywords rather than a cut and paste solution. Any code (JS or CSS) can be included. It depends on the specific target as to what keywords you place there.

If those keywords work for you with no errors, then they are probably correct. The worst that can happen is you use a keyword which is too generic and therefore limit the optimization. For example. If you used the keyword '.js', then all javascript would be ignored and no benefit would be gained.

But it looks as if you have got the hang of it since they "seem" to be targeting the specific module.
kaost replied on at Permalink Reply
Thank you! Everything works great.

define( 'MISER_KEYS_IGNORE',array('embedvanilla', 'remote.js', 'forum/plugins'));


* Strange, when I add this to the site.php file it loads the embed code below the footer. I have no idea why? I have it like this.
define( 'MISER_KEYS_IGNORE', 'embedvanilla');


And it works fine, but when I add array function, it doesn't work.
Phallanx replied on at Permalink Reply
Phallanx
@Kaost
Yes. You are correct. I did originally have it so that an array had to be defined when using the methods. But I took that formatting requirement out when using defines so that you only need a comma separated list (sorry. It's been a while since I had to revisit it).

So. As you were :P
define( 'MISER_KEYS_IGNORE', 'KEYWORD1,KEYWORD2,KEYWORD3,KEYWORDN') );


It's worth mentioning that for the new version of Concrete5 (5.4.2) you will need a new view.php file and new CDNS file. This is currently in test and will be available soon as an update release.
Phallanx replied on at Permalink Reply
Phallanx
Miser 1.7.0 is now available for download as of 14/08/2011.

This is a compatibility update for concrete 5.4.2. Unless you wish to use Miser on a 5.4.2 version of concrete 5; there is no need to update.
Mnkras replied on at Permalink Reply
Mnkras
BTW Phallanx you can make this into a full package for 5.4.2, If you want me to I can, its pretty simple.
Phallanx replied on at Permalink Reply
Phallanx
Hi Mnkras.

Yes. I noticed the hook for rendering is now in place and I manually created a site_events.php (and added an entry) - it all worked tickety-boo. But a package is the right way to go.

I wasn't sure what the order was for packages that subscribe to that event, so erred on the side of caution (and laziness) and just distributed an new view (I also didn't want to have multiple installation procedures for different versions).

I've always said that anyone can make a package out of it. However, the license [quote]doesn't jive[/quote] with the CC5 team so it cannot go into the market.

So I'm all for a package-how do you want to play it?
12345j replied on at Permalink Reply
12345j
yeah, what is the order for packages there?
Mnkras replied on at Permalink Reply 1 Attachment
Mnkras
Attached is a slightly modified version of 1.6.1 that I use on a site,

Its pretty simple :)

Mike
Phallanx replied on at Permalink Reply
Phallanx
@Mnkras
Awww. No Admin page? And all the time I spent on methods and defines...lol.
Mnkras replied on at Permalink Reply
Mnkras
:P I didn't need an admin page, ;) set it up once ;)

thats more of an example on how to implement it.
bretbaldwin replied on at Permalink Reply
bretbaldwin
Phallanx,

I installed Miser 1.7.0 on Concrete 5.4.2 for a website that uses the layout functionality. When in edit mode, the layouts do not seem to be recognized. None of the existing blocks will highlight to edit and no new blocks can be added. I have read both threads (exhaustive) and have not run across this anywhere. Are aware of anyone else having this issue or better yet how to fix it? The website is partywickless.com.

Thanks in advance,
Bret
adamjohnson replied on at Permalink Reply
adamjohnson
Bret,

I just tried this on my test site (5.4.2, 1.7) and the layouts appear to work fine. Make sure you have not overridden header_required.php in /elements and double check your roots /css folder to make sure ccm.base.css (think that's what it's called) is all good.

As a side note as well, Miser creates a cdns_cache.txt file (again, think that's what it's called) in the miser_support directory. When you update miser, you may have to delete that .txt file in order to get the updated list of CDN's (like jQuery 1.6.2).

Let us know what you find.
bretbaldwin replied on at Permalink Reply
bretbaldwin
Thanks for the reply. I checked and I am not overriding header_required.php
and all of the /css files look fine. When I go into edit mode, it loads
like it is in edit mode (with red dotted borders and save edit button at
top), but none of the areas are active to select a block area or add to a
layout. I can save edits to get back out of edit mode, but I can't make any
edits.

I unloaded Miser and it the editing worked fine, but when I reloaded it, it
was exactly the same. I have to say it is MUCH faster! Ijust can't edit
anything. Any other thoughts or suggestions for things to look at?

Thanks again, Bret

-----Original Message-----
From: Concrete5 Community [mailto:discussions@concretecms.com]
Sent: Wednesday, August 24, 2011 5:39 PM
To: bretbaldwin@verizon.net
Subject: Miser - Web site OptiMISER: Miser - Web site OptiMISER
zoinks replied on at Permalink Reply
This happened to me, but not in Edit mode. The layout in general just got screwed up after I installed Miser.

The reason it happened to me is because I was using a bit of javascript to style a Twitter feed and the javascript had positioning elements that screwed up the entire layout once Miser took it and moved it to the bottom of the code with all the other javascripts (which is what Miser does) because the javascript styling wasn't granular enough or something. So, it was positioning Twitter feed completely different based on the fact that it was now inserting it at the very bottom rather than in the in the middle of the DIV as it appeared in my code. Once I figured this out, the solution was a breeze: I uninstalled Miser.
bretbaldwin replied on at Permalink Reply
bretbaldwin
Thanks for the reply. I do have scripts running facebook connections, but
my layouts themselves are all intact. I just can't edit them. However, I
have found that I can reload the page once I am already in edit mode and the
blocks become editable as normal. I had made some changes to my files to
try and speed things up prior to loading Miser. I am going to go back and
look at those next. I will keep you posted.

-----Original Message-----
From: Concrete5 Community [mailto:discussions@concretecms.com]
Sent: Thursday, August 25, 2011 8:09 AM
To: bretbaldwin@verizon.net
Subject: Miser - Web site OptiMISER: Miser - Web site OptiMISER
zoinks replied on at Permalink Reply
I do also know that the edit mode buttons are on z-index 5. If you have a higher z-index "covering" up the edit mode, you won't be able to click and edit. This happened to me as well. :) Not sure why the z-index is so low, seems like a bad choice.
Phallanx replied on at Permalink Reply
Phallanx
@bretbaldwin
Make sure that the concrete5 cache is "OFF" and that you delete all files in the cache directory. If it recovers on a reload, that is usually a sign of cache interference.

If you are still experiencing problems; is it possible for you to pm me with a link to your site so i can take a look?
bretbaldwin replied on at Permalink Reply
bretbaldwin
It turns out that a piece of js that enables xfbml (facebook) functioning in
html5 was preventing the edit mode to work properly. Once this is removed
Miser works as intended with all of the speed improvements and editing
capability. Thanks to all for your suggestions. Phallanx, thanks for your
help in identifying the problem.
Phallanx replied on at Permalink Reply
Phallanx
@bretbaldwin
Well. To be fair. I didn't find out much apart from some JS errors. It was your doggedness and persistence that found the facebook problems.
jordanlev replied on at Permalink Reply
jordanlev
I'm running into issues when the user is in edit mode. If I set MISER_COMBINE_JS to FALSE in my config, the problems go away. But since I think combining JS files is the biggest optimization benefit to MISER, I don't want to have to do this.
The problem is when the user saves a block, the spinner comes up and never goes away. If you reload the page, you can see that the changes have been successfully saved and are now on the page, so the problem is something with how the javascript isn't handling the response from C5 about the success of the save operation (or something like that)?

I've emailed @Phallanx about it but haven't heard back, I assume he's on vacation or otherwise busy, so in the meantime I thought I'd see if anyone else has come across this and might have a solution?

Thanks.

-Jordan
Phallanx replied on at Permalink Reply
Phallanx
Jordanlevs problem was traced to the CDNS_cache.txt file (the cache for the CDNS located in the "miser_support" directory).

The cache is supposed to be generated when you first run Miser and should not be in the zip file download of Miser from sourceforge. The result was that the cache file contained the jquery CDNS for Concrete 5.4.2. and when used with CC 5.4.1.1 (Jordanlevs installation), this obviously caused problems.

The file was deleted and Miser was allowed to regenerate the cache and this resolved the issue.

The file has now been removed from the zip file at sourceforge.
tsilbermann replied on at Permalink Reply
tsilbermann
I tried MISER and it works very well for my site - got very good support/help solving a small problem -thanks a lot for that tool :-)

Torsten
tsilbermann replied on at Permalink Reply
tsilbermann
Hi Guys - after using MISE the google analytics-code (i took it in the head-tag before the body-tag) what can i do to get it back ?

Regards Torsten
Phallanx replied on at Permalink Reply
Phallanx
@toddihh
MISER (by default) moves GA to the end of the page. This is the preferred location for performance.

However, MISER can leave the code in the HEAD (but still move it to an optimised location) by adding the following to your site.php

define( 'MISER_ANALYTICS_LOC',1);
jordanlev replied on at Permalink Reply
jordanlev
Was just responding to another forum thread about pros and cons of using Google CDN for the jQuery library, and I realized that it might actually be faster to *not* use that with MISER. Because MISER is compressing all javascript into a single file, it's possible that it will be faster to include the extra size of jquery in that single merge.js file than it would be to make the additional http request to the Google CDN for it.
Unless the user has the Google CDN jQuery already cached in their browser...

Curious to hear your thoughts on this (I don't think there's actually a single right or wrong answer, and it's probably not a big difference one way or the other -- but it's interesting to think about).

-Jordan
adamjohnson replied on at Permalink Reply
adamjohnson
That would be easily tested by just adding jQuery to the exclude list, or perhaps removing the jQuery CDN reference form miser_cdns.php.

One thing to note though is that, jQuery when hosted locally and minified is 94kb. When you get it gzipped from Google, its 33kb--a pretty big difference (most people on shared hosting don't get to have gzip enabled).
jordanlev replied on at Permalink Reply
jordanlev
This is a really good point -- yeah if your server doesn't use gzip, then I'd think it's worth an extra http request to save 60k.
Phallanx replied on at Permalink Reply
Phallanx
There is a setting to turn off CDN usage. It has a bug when used from the site.php which I have already fixed for the next release, but you can set the Use_CDNS to FALSE at the top of the miser.php.

The big pro for CDNs is that there are many locations around the world that the file can be downloaded from. Having it on your server (say in the US) means that people in (say) Australia have to download it from half-way across the world. It is of course a lot faster for them to download it from a server in their own country.

It is also an advantage to off-site caching. Since the CDNS are well known and accessed regularly; caches all around the world are much more likely to have them cached already. This is especially true of the ISP caches on local nodes.

The biggest downside of CDNS is that they break your site on the rare occasions that they go down. I have thought about local fall-back for this scenario...... just haven't gotten round to it.
jordanlev replied on at Permalink Reply
jordanlev
re: fallback -- you're probably already aware of how to do it, but just in case:
http://stackoverflow.com/questions/1014203...
Phallanx replied on at Permalink Reply
Phallanx
Miser 1.7.1 is now available for download as of 10/10/2011.

This is a minor update to add some useful features to aid development of the Admin interface package for the Concrete5 back-end.

Upgrades from previous versions is optional.
jordanlev replied on at Permalink Reply
jordanlev
What are the new features? Are there new config keys for them or just functionality fixes that make the dashboard work better?
(And what's the "admin interface package"?)

Thanks!
Phallanx replied on at Permalink Reply 1 Attachment
Phallanx
@ Jordanlev
Mainly stuff enabling clearing of the cache, getting the size of the cache etc. See the readme (has a list of all features).

The package is a single page in the Admin interface that I'm playing with (see screenshot).
bagonyi replied on at Permalink Reply
If we are extensively using the caching system of concrete5 (to store API call results), we cannot really use Miser, as it requires the cache being turned off, right?
Phallanx replied on at Permalink Reply
Phallanx
@bagonyi
It is "recommended" that the CC5 cache is turned off since it "sometimes" bypasses Miser.

If you are looking at using Miser, then obviously even with your cache enabled - things are a little sluggish. So what have you got to lose by trying?
adajad replied on at Permalink Reply
adajad
Dang it... I'm on a 5.2.17 version of php on a Windows server running Apache 2.2, so I guess I'll have sit this one out.
Phallanx replied on at Permalink Reply
Phallanx
@adajad
I believe Mnkras has used it on older php versions (earlier in this thread he says what he changed). But I obviously cannot support modified versions.

But as I understand it. Version 5.2.17 is more recent than 5.2.5.
fastcrash replied on at Permalink Reply
fastcrash
Awesome!, i have implan it on my site, and work well - much faster, but the cache folder geting bigger and bigger, it's that fine?
its almost 120mb now.
assume i have 1000 article, is miser cache 1000 article js and css and store it in cache folder or just once? cuz its just blog_type not single page. and the js and css ara same/ no different

pardon me, not quite well in english, hehee..

nb bonus => i want to buy domain, but there is yahoo name on it, its that okay? //OOT - do not answer it if u dont want :)
Phallanx replied on at Permalink Reply
Phallanx
@fastcrash
Miser caches Javascript and CSS only (it doesn't cache content). It does this for each page though. If you are editing constantly (the styles, layouts, adding/removing blocks etc) then it will grow quite rapidly as it saves new files for each changed CSS and Javascript.

However. Once everything has settled down and you are happy with the look and feel of your site. It is safe to delete the files in the cache. Miser will then regenerate the files it needs as and when needed meaning that you should end up with a lot less files.
fastcrash replied on at Permalink Reply
fastcrash
wow, such a fast respone.

I see, so that's how the mechanism cache is.
you are right, i still in development mode and often change everything.

btw, i upgrade to miser 1.7.1, but there is no misser tab in the dashboard, like like the image you show before?

and yeah.. you use easy news to eh? hehehee
Phallanx replied on at Permalink Reply
Phallanx
@fastcrash
The admin package shown in the image hasn't been publicly released. It is a development exercise to see what (if any) new features would be required/useful for an admin package.
buurvrouw replied on at Permalink Reply
buurvrouw
I installed miser and see some positive speed effects.
However i'm getting this error on the bottom of all pages when logged in:

Fatal error: Call to undefined method View::outputFooterItems() in /mnt/web8/12/23/51540923/htdocs/concrete/concrete/libraries/controller.php on line 467

This is on line 467 from the file:
$v->outputFooterItems();

Does anyone know how i can fix this?
Phallanx replied on at Permalink Reply
Phallanx
@buurvrouw
Miser doesn't modify any PHP. Are you sure you don't get this error when Miser isn't installed? If you delete the view.php in the top level "libraries" directory; does it still exist?
buurvrouw replied on at Permalink Reply
buurvrouw
I just tested your suggestion. With view.php removed it doesn't display the error, so it must be something to do with miser.
But i'm on a strato hosting like rckDsgn in the top of this discussion.

In my config i have:
define('BASE_URL', 'http://subdomain.domail.nl');
define('DIR_REL', '');

In a php.ini i have:
safe_mode = off
cgi.fix_pathinfo = 0

And in my .htaccess:
# -- concrete5 urls start --
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
# -- concrete5 urls end --


I hope you can help me resolve this issue.

Thanks,
buurvrouw
buurvrouw replied on at Permalink Reply
buurvrouw
oh, and in my miser_bridge_C5.php i have:
$this->set_root(DIR_BASE);
placed before the first line: // Cache directories
Phallanx replied on at Permalink Reply
Phallanx
What version of concrete are you using?
buurvrouw replied on at Permalink Reply
buurvrouw
# Concrete5 versie
5.4.2.2
Phallanx replied on at Permalink Reply 1 Attachment
Phallanx
Hmmm. The forum won't let me post the attachment.

----a little later.....

Aha. No longer allows php extensions.

Try replacing the view.php (in the top level libraries dierctory) with the attached view.php.
buurvrouw replied on at Permalink Reply
buurvrouw
Excellent! The error is gone.
Thanks for your very quick help!
Phallanx replied on at Permalink Reply
Phallanx
@buurvrouw
OK. I will update the Miser at sourceforge once 5.4.2.2 has been released through the network
fastcrash replied on at Permalink Reply
fastcrash
i upgrade from 5.4.2.1 to version 5.4.2.2, there is no such error.
everything is fine. i use miser 1.7.1
Phallanx replied on at Permalink Reply
Phallanx
@fastcrash
The problem will only exist if you have a block (or template) that tries to add javascript to the bottom of a page. The CC5 team added the "addFooterItem" to 5.4.2.2. But it doesn't affect Miser itself (or its optimisation), only the view.php - a slightly modified core file to call Miser.
Responsive replied on at Permalink Reply
Responsive
Hi
I installed the files but now I am unable to use the Customize Theme facility as making any changes does not give results. Seems it is just ignoring the changes and using the default css. Any ideas what may be wrong.
thanks
Phallanx replied on at Permalink Reply
Phallanx
@silko
Did you turn off the concrete5 cache?
Responsive replied on at Permalink Reply
Responsive
yep turned the cache off as requested, also turned it back on again and the same. Do I need to install jsmin.php as I read that this was not needed any more and if so are there guidelines where this should be installed ie directory.

thanks
Phallanx replied on at Permalink Reply
Phallanx
@silko
Shotster is right. You need the cache enabled for using the customise.I've just tried with the Plain Yogurt theme (cache enabled) and I could change things like the header/logo font colour etc with miser on. But adding "custom CSS" didn't work at all (whether Miser was enabled or not).

It looks like the preview facility actually inserts HTML into the preview to show the changes, and doesn't modify the css until you press save. Therfore, I cannot see any reason why Miser should prevent the preview working.

If you delete the view.php supplied with Miser; does it do as expected?

Jsmin just minifies the javascrpt, but it is included with the install so if it isn't present in concrete5-it will automagically use that one (no installation necessary). If you didn't extract the jsmin, then it will just mean that your JavaScript won't be minified, but Miser will still do everything else.
Responsive replied on at Permalink Reply
Responsive
Hi Phallanx

Ok I kept cache disabled and removed the view.php and the customize theme works now when using save. Placed the view.php back and the customize theme window shows results but using save it does not update the website.
Phallanx replied on at Permalink Reply
Phallanx
I am unable to replicate this on 5.4.2.2.
What version of concrete5 are you using? Which Theme?
MrGrowBizz replied on at Permalink Reply
MrGrowBizz
Phallanx, Thanks for the code, cut a chunk of time. However, I am unable to edit content blocks with miser installed, added on 2 sites with the same results. Tried to remove the miser files to edit and received numerous errors referring to the absence of the files. How do I fix to edit content and how do I remove miser? Thanks!
Phallanx replied on at Permalink Reply
Phallanx
@MrGrowBizz
To disconnect miser from CC5 you only need to delete the view.php in the TOP LEVEL "libraries" directory.

Are you sure you are using the correct view.php? In the "Concrete5" directory after extraction of the zip file, there are different view.php s for the different cc5 versions. If you are using 5.4.2.2 then you will have to download the view.php attached earlier in this thread since Miser 1.7.1 was released before 5.4.2.2 was released.
MrGrowBizz replied on at Permalink Reply
MrGrowBizz
Same result with the attached view.php. Content block opens in edit but no text to edit or can not add text. Figured out I needed to get rid of the view as well to remove miser. Once removed, no problem. A quick look indicates the content block may be the only block effected.
Phallanx replied on at Permalink Reply
Phallanx
@MrGrowBizz
Hmmm. What version of cc5 (5.4.2.2)? Can you PM me a link to your site so I can see if there is anything obvious?
MrGrowBizz replied on at Permalink Reply
MrGrowBizz
Phallanx, Yes 5.4.2.2, I will throw on another very simple sight later today and see if problem continues. Thus far have added and removed on 2 different sites, one that is very fast to begin with, and same result.
Shotster replied on at Permalink Reply
Shotster
If I recall correctly, in order to preview changes when customizing a theme through the dashboard UI, the C5 cache must be enabled. IOW, the preview relies on the cache.

It's unfortunate, but I'm pretty sure that's the case.

-Steve
dlntx9 replied on at Permalink Reply
Is it still necessary to modify the htaccess file as outlined in the original concrete on steroids thread?
adamjohnson replied on at Permalink Reply
adamjohnson
Modifying the htaccess file is optional. As I recall, Phallanx was just suggesting people use Gzip and other best practices as outlined in the HTML5 Boilerplate:

https://github.com/h5bp/html5-boilerplate/blob/master/.htaccess...
Phallanx replied on at Permalink Reply
Phallanx
@dlntx9
It is not "necessary" but hugely recommended and will make an enormous difference to your sites speed IF (and only if) the Apache modules are enabled.

The htaccess changes do two things.

1. Enables compression. (obvious advantage here)
2. Ensures all common file formats have an appropriate "lifetime" for offsite caching. This makes remote caches much more likely to cache your files.
industryslave replied on at Permalink Reply
Wow. This is awesome! Thank you so much for putting the time into creating this. It is solving the major issue I had with concrete. I am doing a barebones implementation of the HTML5Boilerplate and the only thing I am having trouble working out how to do is to keep the inline chrome frame prompt for ie6 at the bottom of the page.

[code]
<!-- Prompt IE 6 users to install Chrome Frame. Remove this if you want to support IE 6. -->
<!--[if lt IE 7 ]>
<script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
<script>window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})</script>
<![endif]-->

[code]

I am quite sure there is a way to tell Miser to ignore this block. I am just missing it.

Thank you again for all of your work. You rock!
Phallanx replied on at Permalink Reply
Phallanx
@industryslave
Yes. You can tell miser to ignore stuff (amongst other things).
Try adding the following to your site.php
define('MISER_KEYS_IGNORE','CFInstall');
PatrickHeck replied on at Permalink Reply
PatrickHeck
I had a problem when editing page attributes that use TinyMCE. The Editor just didn't show up anymore. I figured it would be the easiest to diable Miser while in edit mode. To do that I searched for the following line in libraries/view.php:
$o = Loader::helper('miser');

after that I added:
if ($editMode) {
 $o->enable(false);
}

Now the Editor works fine again. Hope this information helps people that run into the same kind of problem.

Patrick
MrGrowBizz replied on at Permalink Reply
MrGrowBizz
Patrick, Thanks! Just what I needed! T
Phallanx replied on at Permalink Reply
Phallanx
@PatrickHeck
Can you describe how to recreate this problem?
PatrickHeck replied on at Permalink Reply
PatrickHeck
sure phallanx,

you can reproduce it like this:

- Install Concrete5.4.2.2
- Install Miser 1.7.1
- Use this libraries/view.php:http://www.concrete5.org/community/forums/customizing_c5/miser-web-...
- Change line miser.php:461 from
$fp = fopen($path, "c");

to:
$fp = fopen($path, "a");

according to:http://www.concrete5.org/community/forums/chat/concrete-on-steroids...
- Create attribute of type "Text Area"
- Choose "Rich Text - Simple"
- Edit any page
- Add newly created attribute to properties
- Rich Text Editor will not show up

This is my environment:
# concrete5 Version
5.4.2.2
# concrete5 Packages
None
# concrete5 Overrides
helpers/miser.php, helpers/miser_support, libraries/view.php
# Server Software
Apache/2.2.4 (Ubuntu) DAV/2 PHP/5.2.3-1ubuntu6.5 mod_ssl/2.2.4 OpenSSL/0.9.8e
# Server API
apache2handler
# PHP Version
5.2.3-1ubuntu6.5
# PHP Extensions
apache2handler, bcmath, bz2, calendar, ctype, date, dba, dom, exif, filter, ftp, gd, gettext, hash, iconv, json, libxml, MapScript, mbstring, mcrypt, mime_magic, mysql, mysqli, openssl, pcre, PDO, pdo_mysql, posix, Reflection, session, shmop, SimpleXML, soap, sockets, SPL, standard, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl, zip, zlib.
# PHP Settings


Hope this helps.

Patrick
Phallanx replied on at Permalink Reply
Phallanx
@PatrickHeck
Many thanks. It looks like an ordering issue. The "succinct" way round it is to put it into the head by adding the following to your site.php
define('MISER_KEYS_HEAD','tiny_mce');


Obviously not the ideal position for it (in terms of performance), so I will find out the exact cause and update it.

Thanks also for (indirectly) pointing out the fact that the
$fp = fopen($path, "c");

is still present. Not sure how it got missed (version 1.4.1), but it will be changed for the next update.[NOTE: It only affects PHP versions older than 5.2.6]
PatrickHeck replied on at Permalink Reply
PatrickHeck
I'm glad I could help.
And thank you for creating Miser - it's a great piece of software.
frz replied on at Permalink Reply
frz
Post test

Just testing some anti-spam stuff on a thread with lots of monitored emails
frz replied on at Permalink Reply
frz
again...
andrew replied on at Permalink Reply
andrew
Yeah could this be a longer thread please?
Phallanx replied on at Permalink Reply
Phallanx
[quote]
Yeah could this be a longer thread please?
[/quote]
lol. Sure, when you release 5.5 ;)
admin replied on at Permalink Reply
Hah. No doubt. Sorry we're sort of hijacking. We're testing the mail functionality out on the longest threads in the site.
Phallanx replied on at Permalink Reply
Phallanx
@admin
No probs. You've been hammered recently.

Getting back to the thread.....

What a fantastic job the peeps at CC5 have done in 5.5 to address speed issues. My bench marking has shown that the "time-to-first-byte" has halved and, since Miser couldn't do much about that; I'm pleased as punch! Miser obsolete? Not yet. So. Since there is still a place for Miser I thought i'd finally get off my arse and figure out how to get Miser working with cache. The problem was only with full page cache since sometimes it would be bypassed if full page caching was invoked.

The answer was simple really, but requires a change to the view.php in the libraries directory.

Around line 852 you will see in the unadulterated view.php...
$ret = Events::fire('on_page_output', $pageContent);
if($ret != '') {
 print $ret;
} else {
 print $pageContent;   
}
if ($view instanceof Page) {
 if ($view->supportsPageCache($_pageBlocks, $this->controller)) {
  $view->addToPageCache($pageContent);
 }
}



This should really be
$ret = Events::fire('on_page_output', $pageContent);
if($ret != '') $pageContent = $ret;         
print $pageContent;
if ($view instanceof Page) {
 if ($view->supportsPageCache($_pageBlocks, $this->controller)) {
  $view->addToPageCache($pageContent);
 }
}


If you are using the Miser Package, the above needs to change to work with full page caching.

If you are not using the package then in Misers view.php located in the top level "libraries" directory.
change
$ret = Events::fire('on_page_output', $pageContent);
$o = Loader::helper('miser');
if($ret != '') {
 print $o->optimise($ret);
} else {
 print $o->optimise($pageContent);
}
if ($view instanceof Page) {
 if ($view->supportsPageCache($_pageBlocks, $this->controller)) {
  $view->addToPageCache($pageContent);
 }
}

To
$ret = Events::fire('on_page_output', $pageContent);
$o = Loader::helper('miser');
if($ret != '') $pageContent = $ret;         
print $o->optimise($pageContent);
if ($view instanceof Page) {
 if ($view->supportsPageCache($_pageBlocks, $this->controller)) {
  $view->addToPageCache($pageContent);
 }
}


That will ensure that the output from miser is saved to the full page cache.

Of course. Clear/delete cache, blah, blah.

The Miser next release (1.7.2) will have these changes already implemented in the supplied view.php.
MrGrowBizz replied on at Permalink Reply
MrGrowBizz
Phallanx,

This is terrific News, particularly that you have verified 5.5 in cutting speed and a miser cache solution! If only I had my hands on 5.5!

You have mentioned the "package" a couple times, but have missed finding reference to its release somewhere. How does it differ from what was downloaded on your site, and where does one find it?

Great work on your behalf!
andrew replied on at Permalink Reply
andrew
Dude that's awesome. I'm glad to hear that 5.5 seems to substantively improve speed for people other than us – and that those who want to really tinker and tune their sites will have new and better tools to do it.
Phallanx replied on at Permalink Reply
Phallanx
@andrew
Yup. You've obviously been on quite a tidy up.

The issue with Miser being bypassed is (IMHO) a bug in the view.php since any piece of code that hooks the "on_page_output" event will get bypassed if there is a cache file (it will exit around line 783 before it gets there). If an event is hooked, then the "ret" variable is output, but the pageContents is cached instead. So anything that modifies the html in the event will never get saved.

Nice UI update too :)
fastcrash replied on at Permalink Reply
fastcrash
Woooaaaah! cannot wait for the next c5 version 5.5, so exited
i think it will be the big prize in the 2012, thehee...
zoinks replied on at Permalink Reply
gimme gimme gimme!!!

I was recently realizing while on the Designers Talk forum that people still looking for a designer-friendly CMS are in the dark about C5. I'm sure with 5.5, C5 will get fast exposure if it becomes part of hosting solutions, as was mentioned, it will blow up quickly.
MrGrowBizz replied on at Permalink Reply
MrGrowBizz
Getting back to this thread’s topic about Miser, have to say I have a site that would not be presentable without it! In the need for speed I have (host) enabled Gzip, zlib, and FastCGI, made a majority of the edits suggested throughout this forum, optimized every freeking image, and spent a ton of time screwing around with C5’s caching quirks. While all of these moved speed by inches, Miser moved it by miles.

While initially having a Mizer misconfiguration issue (my fault), it still dramatically improved speed out of the blocks. Once properly configured, it has cut loading times by more than half even with initial page loads using cache. The biggest issue now is "time-to-first-byte” which hopefully will in fact be cut in half with 5.5...time will tell...we will see.

Thanks again Phallanx!
Phallanx replied on at Permalink Reply
Phallanx
@ MrGrowBizz.

I'm glad we got a good result and resolved all your issues.

------------
To expand a little further on the issues for the benefit of others; the first one was that there was a typo in the site.php (missing closing quote). This was the reason for the 20 second load times (without miser)and once that was corrected, CC5 exhibited it's usual loading behaviour.

Once that was addressed, the issue with Miser was that only the miser.php file and the miser_bridgeC5.php file had been extracted from the zip. Additionally, the miser_bridgeC5.php was located in the same directory rather than in the "miser_support" directory. Miser requires that the zip is extracted in the same structure as the zip file for normal operation. Miser will still work (even if it is the only file-it is designed to degrade gracefully) but you won't get the CDNS, minification or the CC5 specific settings that allows miser to know what CC5 is sensitive to in ordering.

The fix was simply to download miser again and extract the entire zip.
fastcrash replied on at Permalink Reply
fastcrash
phalanx, i got the headache,
how can i put the .js file after merge.js in the footer page?

there is conflict,miser always create cache file evertime i refresh the page.
but if i remove the addon, miser work properly, only one cache file.

so i think its because js conflict.

i success move the addon js to ignore and jquery to the head
define( 'MISER_KEYS_IGNORE', 'jquery.socialshareprivacy.min.js');
define( 'MISER_KEYS_HEAD', 'jquery.js'));

but the error still occur, the last thing i have not try is put the addon js after miser merge.js, how can i do that?
if cannot, can we move the merge.js to the head?, not in bottom

the addon ishttp://www.concrete5.org/marketplace/addons/social-share-privacy/...

and yeah, your last attachment view.php is php short tag - i got error before :)


nb : take back my word, the error still occur after i insert jquery.socialshareprivacy.min.js after merge.js

just give up.
Phallanx replied on at Permalink Reply
Phallanx
@fastcrash
Miser will create a file if there is a change in the javascript. If the javascript (or a part of it) is randomly generated on each page-load, then you will see Miser creating a file every time you reload a page.

The method of coping with this sort of Javascript is to tell Miser to not place it in a file by adding the following to your site.php e.g.
define('MISER_KEYS_NO_FILE','social-share-privacy');


Simply moving the merge file to the head would break your site since many scripts are order dependent.
bryanlewis replied on at Permalink Reply
bryanlewis
I don't think this works with 5.5 yet. I'm getting an error when I try to install it.
Phallanx replied on at Permalink Reply
Phallanx
@bryanlewis
1.7.2 (with support for 5.5) will be released when CC5.5 is rolled out through the Admin panel (i.e when the CC5 team are confident it works).
fastcrash replied on at Permalink Reply
fastcrash
yes, maybe there is some js script randomly generated code on each page-load in socialshareprivacy.js, that why miser creating a file everytime reload the page.

the cache for that js file size is no different, 334,249 bytes - only the name is different.

i try your suggest, still not work, well just give it up.
thanks for fast reply. i'm stil using 5.4.2.2
PatrickHeck replied on at Permalink Reply
PatrickHeck
Hey fastcrash,
the ssp js file should be the same every time it's loaded, only the code, that's put inside the page varies every time because it uses uids. Maybe you can turn off JS minification and try to post two of the merge.js files to see what the difference actually is.
Patrick
fastcrash replied on at Permalink Reply
fastcrash
you are right patrick, thanks, you are really a savior.
but now the both of this cool addon work.

i set this to miser.php
<!-- Sorted by Miser 1.7.1 in 10.606 Secs --> //result when set to TRUE, always create merge.js
<!-- Sorted by Miser 1.7.1 in 0.179 Secs -->  //result when set to FALSE, no merge.js created
private $endis_js_combine   = FALSE;          //Enable/disable combining javascript into 1 file


as a result all the js put in bottom not combining into 1 file.

well, miser work after all, i really happy.

i know i'm gredy :), is there a setting to merge all the js except ssp js?

thanks patrick,love u man, phallanx too..
Phallanx replied on at Permalink Reply
Phallanx
@fastcrash

define('MISER_KEYS_IGNORE','jquery,socialshareprivacy');


in the site.php works for me.
fastcrash replied on at Permalink Reply
fastcrash
OMG!, you are right phallanx it's work!, dumb of me

define('MISER_KEYS_IGNORE','jquery,socialshareprivacy');

i see, this is how to re-ordering the output, so the jquery will output first before socialshareprivacy.
i try this, but the jquery alway output after socialshareprivacy
define( 'MISER_KEYS_HEAD', 'jquery.js'));
define( 'MISER_KEYS_IGNORE', 'jquery.socialshareprivacy.min.js');

thats why it's error.

I'm really happy, both of them work like a charm now, hountoni arigatou <img src="http://images.forum.idws-static.com/images/smilies/onion-69.gif" />
Phallanx replied on at Permalink Reply
Phallanx
@fastcrash
Do itashimashite
fastcrash replied on at Permalink Reply
fastcrash
MIser threat different because of space
define('MISER_KEYS_IGNORE','jquery.js, socialshareprivacy'); //miser not work
define('MISER_KEYS_IGNORE','jquery.js,socialshareprivacy');  //work like a charm!


just for someone who don't know, or maybe just me :)
Phallanx replied on at Permalink Reply
Phallanx
@fastcrash.
OK. I'll see what I can do to poka-yoke it.
nicole7 replied on at Permalink Reply
I've been searching and searching for ways to increase the speed of my concrete 5 website. I just found this information on Miser. However, I do not find directions on how to implement this. Is this a program you download through Concrete 5? Please give some simple instructions so that I can implement the MISER to speed up my site. Thanks.

Nicole
http://www.quickbag.us
Phallanx replied on at Permalink Reply
Phallanx
@nicole7
Miser is not available from within Concrete5. It is installed manually.

You can download the zip file with the link to sourceforge at the top of the page. There are install instructions in the readme contained in the zip.
shondy replied on at Permalink Reply
shondy
I am having the same issue as buurvrouw above where I was getting an error due to the loading of javascript into the footer ( I think it is the mega menu that was casuing it but not sure 100%). Using the version of view.php that you provided solved the issue with the error, but it is not loading my css files (any of them). I have prettylinks enabled so do you think I need to modify something in the MISER config settings to get the css files to load? I checked the source and MISER is loading the javascript into the footer and it is minified as it should be so I am definitely headed in the right direction!
shondy replied on at Permalink Reply
shondy
Update- I see that the css file is merged and is located in the head of the HTML but it either doesn't like the path or something else is amiss:

/files/cache/css/..._merge.css

I can't seem to resolve the path issue in Firebug and I am seeing this when I try to view the css file in Firebug:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /files/cache/css/..._merge.css
on this server.</p>
</body></html>

I am assuming this is standard ops. I can ftp the cached file to my local machine and open it, and even use the web developer toolbar to attach the local copy of the cached stylesheet- just can't figure out what gives. I had prettylinks enabled but turned them off and that didn't change anything. Even flushed the cache and deleted the erroneous cached files on the server with no luck. I got no styles and its bugging me!
Phallanx replied on at Permalink Reply
Phallanx
@cschondel

What are the permissions on the "/files/cache" directory? Try setting it to 755 (make sure it is propagated to the files also)
shondy replied on at Permalink Reply
shondy
OK- that definitely made a difference, but the weird part is that I set the permissions to the cache , css and js folders, and deleted the cache files, but when they were re-created they did not pick up the permissions of the parent. I'm not sure what to do to fix this. It seems like any new files created in the cache folder have no permissions applied to them. I can manually set the permissions but that obviously makes no sense.
Phallanx replied on at Permalink Reply
Phallanx
@cschondel
Try setting the permissions on the cache folder to 2755.

http://www.zzee.com/solutions/linux-permissions.shtml#setuid...
shondy replied on at Permalink Reply 1 Attachment
shondy
I did that but still any new caches that are created are not picking up the permissions - I'm stumped.

See attached.
Phallanx replied on at Permalink Reply
Phallanx
And what is the permission on the files/cache/css directory?
shondy replied on at Permalink Reply
shondy
755 on both the css and js directories.
shondy replied on at Permalink Reply
shondy
I reset the file permissions for the entire site and that seems to have cleared things up. I will keep my eyes on it. I have nothing but the utmost respect for you and what you have done to improve C5. I love this CMS! Now I just have to get off of shared hosting!
shondy replied on at Permalink Reply
shondy
One more quick question- currently is there no way to clear the cache files created with MISER unless done manually? I read the readme but am not clear on what to do with this

// clears the CSS, JS and CDN caches
$m->cache_clear( FALSE );

I see that you are in development of an admin for this which will be rather awesome when complete I am sure...
Phallanx replied on at Permalink Reply
Phallanx
@cschondel
Glad you got the permissions sorted.
Miser has the capability to clear its cache files, but without the admin addon (which has been complete for some time, but only available to commercial customers) you have no way of invoking it.
shondy replied on at Permalink Reply
shondy
I am using this on a NPO - can you give me some direction on obtaining a license so that I would have an admin section available? Sorry- I just saw a lot of legal mumbo jumbo in this thread but nothing clear cut on how to obtain it! I can email the particulars if you need.
Phallanx replied on at Permalink Reply
Phallanx
@cschondel
Email me with at the address in the Miser readme and we can discuss details. I don't actively promote the commercial side, just that those that purchase a license also get the addon as a value-added component.
Phallanx replied on at Permalink Reply
Phallanx
To add a bit more to the permissions problem so that others are aware.

It seems that this particular host (Network Solutions) restricts any file created within PHP to the permissions 640 (rather than 644 for most hosts) and it is up to the php script to chmod it to something more suitable.

So here's the solution:

Locate around line 651 in the "fsave" function, the line
fclose($fp);

After this and before the "return TRUE" insert the line
chmod($path,0644);


Whilst this is rare for hosts to do, this will be incorporated into the next release of miser.
DBKG replied on at Permalink Reply
Launched first c5 sites in the fall and just found this thread. On the 5.4.2.x sites I have hosted on a VPS account, so far the install works "out of the box." Couldn't have been easier. So far, no conflicts. Haven't done any page load testing, but each site sure feels a lot zippier. Thanks much!
Phallanx replied on at Permalink Reply
Phallanx
@brandsmarter
Great. If you do run into any problems, then this thread is the place to post so that others can benefit from any solutions.
Phallanx replied on at Permalink Reply
Phallanx
Miser 1.7.2 has been released as of 24/01/2011.

This update is a compatibility update to support concrete 5.5.x.
There have been a few minor changes (e.g. the permissions issue that was outlined) but apart from that it is mainly a new view.php and updates for the jquery CDNS.
fastcrash replied on at Permalink Reply
fastcrash
congrat!, i don't know 1.7.2 already out.

btw phallanx,
i have thinking back, how if i minified(create) manually merge.js and merge.css? i don't have a lot of add-on, so i think i just merge all js/css add-on manually, althought maybe they are not loaded on some page.

what different than using miser?

ps : thanks for the @import link.
Phallanx replied on at Permalink Reply
Phallanx
@fastcrash
So. You are going to go through all the core files, addons, themes and templates. Remove all the references (addHeaderItem) and hard-coded links. Add a single reference to your merged files and do that every time you add a block or update concrete, or a theme or some css? (assuming you get everything in the right order for script dependencies).

Rather you than me :)

The other things that miser brings to the table (apart from merging and minification)is that it replaces local files with CDNS and those files it cannot merge, it sorts and moves around to optimal locations. Additionally (for the new EU directive). It can hide google analytics until a cookie has been accepted.
WilliW replied on at Permalink Reply
Hi,

cool project. What do I have to do, to get my theme stylesheets merged?

<link rel="stylesheet" href="<?php echo $this->getStyleSheet('style.css')?>" />
  <link rel="stylesheet" href="<?php echo $this->getStyleSheet('typography.css')?>" />
Phallanx replied on at Permalink Reply
Phallanx
@WilliW
I'm not quite sure what you mean.
If you are thinking that it takes style sheets and just sews them together..... It doesn't.

It scrapes the final HTML page looking for style sheets and inline css and puts all of it in a file including core, blocks and anything else it can find. It then replaces all links that used to point to the original files with a link to the merged file.
PatrickHeck replied on at Permalink Reply
PatrickHeck
Just a quick note about a problem that appeared with Miser for me: There was a superfluous small button in every modal dialog. I fixed it by changing the view.php to disable Miser completely if a user is logged in. See the bug report for details:http://www.concrete5.org/index.php?cID=320370...

Patrick
Phallanx replied on at Permalink Reply
Phallanx
Which version of concrete are you using?
PatrickHeck replied on at Permalink Reply
PatrickHeck
5.5.2.1

But I had this problem since 5.5
Phallanx replied on at Permalink Reply
Phallanx
OK. I can replicate it and should have a solution by the end of the weekend.
Phallanx replied on at Permalink Reply
Phallanx
Miser 1.7.3 has been released as of 28/04/2012.

This update addresses the spurious button on dialogues and adds the jquery.JCrop CDN.

After updating you must delete the "CDNS_cache.txt" located in the "miser_support" directory and it is recommended that you delete the CSS and JS directories (and their contents) in "<root>/files/cache/"
PatrickHeck replied on at Permalink Reply
PatrickHeck
You're awesome Phallanx :-)
Thanks for your great work.
okapi replied on at Permalink Reply
okapi
I'm experiencing a problem with miser and advanced user group permissions.
When a group has defined permissions to edit areas and/or blocks on a page, a user of that group is logged in and the page is in edit mode, the script that highlights the editable blocks and also enables the edit menu on mouse click doesn't work. While the dotted borders around editable areas and blocks are visible, they are not (gray) highlighted on mouseover and no edit menu pops up.
As soon as all miser files are deleted, everything works flawlessly.
Maybe a javascript conflict? Can anybody confirm that problem?

(Concrete5 5.5.2.1, Miser 1.7.3, Firefox 12, IE 9, Safari Win 5.1.5)

Cheers,
Michael
Phallanx replied on at Permalink Reply
Phallanx
@okapi
Do you have concrete5 cache turned on?
okapi replied on at Permalink Reply
okapi
No, i have disabled it, according to the readme. I have also been clearing both browser and concrete5 cache a number of times. Interestingly the problem disappears immediately as soon as miser files are not envolved any more.
Phallanx replied on at Permalink Reply
Phallanx
@okapi
And presumably deleted "CDNS_cache.txt" which is the more important one...

If I use the advance permissions (group) the layout is borked with or without Miser (but still editable with Miser).

Do you get any errors reported via the javascript Console?
okapi replied on at Permalink Reply
okapi
The behaviour as described above occurs only if permissions are set for one of the "Add to [name of area]" bars.
As soon as permissions are set for one of them, all other "Add to [name of area]" bars won't react any more on mouseover. As soon as the Miser files are deleted, everything is working fine again.

I have do add, there is no problem with permissions for exsting blocks. It only exists with permissions set for the "Add to..." bars.

Michael
okapi replied on at Permalink Reply
okapi
My apologies, it seems i have messed up the permission settings, now it works as expected.
Phallanx replied on at Permalink Reply
Phallanx
Glad you got to the bottom of it (I couldn't reproduce it).
moosh replied on at Permalink Reply
moosh
Hi,

Seems to be a good module !

But I have some problem to integrate it in Concrete5.5.2.

I've 2 questions :

1/ I setted that in my "header.php" :

$m = Loader::helper('miser');
$m->js_dir('c5/files/cache/js/');
$m->css_dir('c5/files/cache/css/');
$m->enable(TRUE);
$m->minify_css(2);
$m->minify_js(2);
$m->combine_js(TRUE);
$m->combine_css(TRUE);


But when I'm looking with firebug, nothing seems to be merged...

2/ Do you plan to make an addon for c5 ? It can help a lot of guys!
Then, including htacces optimizations :)

Thank you !
Phallanx replied on at Permalink Reply
Phallanx
@moosh
1. You do not need to modify any files. You simply place the supplied view.php in the top level libraries directory and it will get picked up by concrete5. (It's detailed in the readme)

2. There is an addon. It is only available to commercial users.
moosh replied on at Permalink Reply
moosh
1/ ok I will check.

2/ I don't find it XD. Could you provide an url ?

Thank you
Phallanx replied on at Permalink Reply
Phallanx
@moosh
The addon is sent along with the commercial usage waiver. There is no download url.
moosh replied on at Permalink Reply
moosh
Could you send me PM with price ?
Thank you
Phallanx replied on at Permalink Reply
Phallanx
Send an email to the address at the top of the readme and I'll send you all the details.
jordanlev replied on at Permalink Reply
jordanlev
I don't know what the price is now, but I did want to let you know that I've purchased a commercial license for Miser in the past and it was worth every penny. It was a life-saver for me to get a very complex website running at a good speed, and @Phallanx provided excellent support to me when I ran into a problem with it.

Hope it works out well for you too.

-Jordan
moosh replied on at Permalink Reply
moosh
Thank you for the feedback.

Can we exclude js/css file from miser ?
Especially font face because there are some issues with minify/combination.
Phallanx replied on at Permalink Reply
Phallanx
@moosh
Yes. You can put defines in your site.php to control the behaviour.
You can choose files to not be combined, placed into the header/footer, left completely untouched or removed completely.
See the end of section 5 of the readme for the defines currently supported and some examples.
Phallanx replied on at Permalink Reply
Phallanx
Miser uses CDNs to improve responsiveness. Whilst most of the time the CDNS are robust, currently one of those CDN sites is down (cachedcommons.org).

Until it becomes available again, it is recommended that all users temporarily turn off Misers Use CDN option.

For users of the Addon:
Uncheck the "Use CDNS" option in the admin interface.

For users of the download from sourceforge add the following to your site.php:
define('MISER_USE_CDNS',FALSE);


It is not clear whether the site is permanently down or it is just a temporary outage. If the site is not back within 48 hours, I will find alternative CDNS for the files that Concrete5 uses.
Phallanx replied on at Permalink Reply
Phallanx
cachedcommons.org is now back up and running.
tsilbermann replied on at Permalink Reply
tsilbermann
Is it possible to deactivate miser in dashboard - got some problems with Translation Manager?
Phallanx replied on at Permalink Reply
Phallanx
Hi toddihh.
If you have the addon, yes. Just de-select the "Enable" checkbox.
If you don't then you can add
define( 'MISER_ENABLE',FALSE);

to your site.php

Alternatively you can rename/delete the view.php in the libraries directory.

Regards
Phallanx
anchoredbutterfly replied on at Permalink Reply
anchoredbutterfly
I just want to thank Phallanx for this incredible add-on and for outstanding responsive support. Miser has improved my site speed significantly (from 71% to 95% on GTmetrix and from 60% to 80% on Yslow).
Kudos!
Phallanx replied on at Permalink Reply
Phallanx
@anchoredbutterfly
You're very welcome.
tsilbermann replied on at Permalink Reply
tsilbermann
Hey Phallanx,

miser really improves the sitespeed ;-) but i have a problem on tis page:http://schluermann.com/nettolohnrechner/... the external frame has moved to the bottom, under the footer. Any idea how to solve this?

Best regards

Torsten
Phallanx replied on at Permalink Reply
Phallanx
@toddihh
Well. If we ignore the fact that Miser 1.7.3 does not support Concrete 5.6.x ;) ..........

Some Javascript does not lazy load. That is. It executes wherever it is in the page when the browser comes across it. Examples of this are things like the Google Widgets or Google Ads (which Miser already knows about). If such a piece of javascript exists in the page, then Miser will naturally move it to the bottom where it will then execute. The result is that the piece of code sits at the bottom of the page instead of where it is supposed to. This is what is happening on your page.

To fix it, we have to tell Miser not to move it by adding it to the ignore list. I don't know whether this is a block, custom code or whatever, but you have to find a keyword that identifies that block of code.

For example.
If the offending piece of JS is called "external.js" then we need to add the following to the site.php:
define('MISER_KEYS_IGNORE','external.js');


Beware though. If the piece of Javascript relies on another piece of code loaded first (for example, jquery). Then that will also need to be either ignored or forced into header.

This sort of "I Must be Here" code should be avoided wherever possible since it prevents the page from loading until it has finished executing. This greatly impacts performance especially if it has to go off to another site before it can complete.
tsilbermann replied on at Permalink Reply
tsilbermann
Thanks for your fast help - i will try that. ... its running under 5.6 as well (an it seams like the pages loading faster ;-)
Torsten
okapi replied on at Permalink Reply
okapi
My great respect, Phallanx, your incredible software (1.7.3) also makes Concrete5 5.6 lightning fast. The difference between running concrete5 with all cache options enabled and with cache turned off and miser enabled is absolutely amazing! I don't know what magic is going on under the hood, that makes miser by far the best option to encrease performance of concrete5 driven websites, especially on shared hosts!

Too bad that you and the C5 team couldn't find a way to make use of the obvious synergy potential...

Thank you,
Michael
Phallanx replied on at Permalink Reply
Phallanx
@okapi
Beware. The view.php that is supplied with 1.7.3 is not the same as that in concrete5.6.x. Whilst it may seem to work on the surface, it is not currently supported for this reason (and only this reason).

In fact. Ironically. The only reason you really need to override the view.php at all, is so that you can use Miser WITH the concrete5 cache.lol.
okapi replied on at Permalink Reply
okapi
Wow... and lol, after all, it works so nicely!
But seriously, is there a newer version for C5 5.6 than 1.7.3 that i have not noticed?
What would you recommend to do regarding C5 5.6?
Phallanx replied on at Permalink Reply
Phallanx
@okapi
Version 1.8.0 is imminent. It's all working and tested. I'm just figuring out how to fix all the CSS they screwed up in the Admin panel.
okapi replied on at Permalink Reply
okapi
Cool. That's good news! Thanks for the info, i'm really looking forward to that!
admin replied on at Permalink Reply
I'll get on fixing the Admin panel. Stay tuned.
Phallanx replied on at Permalink Reply
Phallanx
@adamjohnson
Thanks Adam.
I'm just updating the ReadMe for the new EU cookie compliance feature and then it just leaves the CSS.
Phallanx replied on at Permalink Reply
Phallanx
Miser 1.8.0 has been released as of 16/09/2012.

This update adds the new "EU Cookie Compliance" feature and adds support for concrete 5.6.x.

See the readme included with the zip package for more details.
okapi replied on at Permalink Reply
okapi
Thank you for the update!

Since Austria still has not ratified the new EU Cookie Compliance, i want to turn that feature off - how can i do that?

I have found one issue with Miser 1.8: it seems to block editing of blocks in stacks. As soon as the Miser files are deleted, blocks in stacks become editable again. Can you reproduce that?
Phallanx replied on at Permalink Reply
Phallanx
@okapi
All the info about the feature is in section 6 of the readme.

I cannot replicate the "stack problem" in 5.5.2.1 or 5.6.0.1.
Are you getting any Javascript errors?
okapi replied on at Permalink Reply
okapi
Thank you, and sorry, i should have read the readme first...

I'm getting no javascript errors but i have exactly the same problem with another installation of Concrete5 5.6 on a different environment/another host, as well as on a third clean C5 5.6 test installation. I can PM a test admin login if you are interested.

So the issue occurs on three different servers, one productive site and two test sites, with the latest firefox, IE 9 and Safari for Windows.
Phallanx replied on at Permalink Reply
Phallanx
@okapi.

OK. I think I've managed to reproduce it on another site.

Try adding the following to the site.php
define('MISER_KEYS_REPLACE','on');
define('MISER_KEYS_FOOT','CCM_TOOLS_PATH');


Does that help?
okapi replied on at Permalink Reply
okapi
Yes! Works nicely now!
okapi replied on at Permalink Reply
okapi
I'm curious what magic these two lines are doing to my C5 installations, and what you think that caused that problem?

Thank you!
Phallanx replied on at Permalink Reply
Phallanx
@okapi
Miser does nothing with the Concrete5 installation (that is why you can remove the view.php and everything reverts back).

In older version of CC5, there was certain Concrete5 in-line javascript that was order dependent (tools path, image path etc). Miser searched for var_CCM and moved it to the bottom after CDNS but before other JS.

The inline JS for the stacks also start with var_CCM so Miser moves them to the same place(seems to be ok on some, not on others, probably an ordering thing again).

All that you are doing by using those defines is replacing the search term "var_CCM with "CCM_TOOLS_PATH" to make the search more specific (maybe "var CCM_TOOLS_PATH" might be better as it is even more specific - we'll see). So Miser will still move the old stuff to the normal location,but the stacks JS will now be included in the merge JS (which it seems happy with).
okapi replied on at Permalink Reply
okapi
Thank you very much for the detailed explanation! I'm sure this is interesting for others too.
Movelifeup replied on at Permalink Reply
Ok, so a few things. Initially, (after installing Miser), I received a MySQL error when I tried to load my website which was fixed after I re-loaded it. Second, my dashboard is gone after I logged in to my website. There is only a white bar where all of the commands should be for accessing dashboard functions. Third, a message displays (where the dashboard controls are after being logged in) and tells me to make sure cookies are activated. I'm using chrome and my cookies are activated...any help would be greatly appreciated

http://www.movelifeup.com

(P.S - I haven't done any work to the website yet, I just started.)
Phallanx replied on at Permalink Reply
Phallanx
First: Miser doesn't use a database at all (not even concretes).
Second: Delete all the files in /files/cache/ and make sure the cache settings are turned off (as it states in the readme).
Third: That's not what it says. Press "Accept". Then read section 6 of the readme.
Movelifeup replied on at Permalink Reply
Thanks for the quick replay Phallanx. I can appreciate timely responses. :)

I mentioned the MySQL error to avoid any confusion and make sure I structurally detailed the outcome of installing Miser. Also I had already done the second thing you requested and no luck. As for the third, (whether or not this is a browser issue is unknown to me), but I didn't see an "accept" button anywhere when that message was displayed. If I saw it, I would have clicked it.

I'm re-installing Miser (after re-installing) concrete because I had tampered with some of the files before and didn't feel like retracing through my tracked work. I thought there might be a conflict in something I altered.

Something to keep in mind is that I'm relatively new at doing this kind of thing so please be patient with me.

Again, thanks for the quick reply. It's very important that I complete this website soon so any support I get is more than appreciated.
Phallanx replied on at Permalink Reply
Phallanx
@Movelifeup
Your webpage invokes multiple (very old) copies of jquery
/packages/cannonf700_innovation/themes/innovation/scripts/jquery-1.4.1.min.js
ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js?v=08c0b0757b915393a6da5bd13794d021

Nether of these are the correct version for concrete5 5.5.2.1 (which requires 1.7.1 and will add it when you log into the admin interface).

This is probably the reason you are having problems.
Movelifeup replied on at Permalink Reply
Thanks for the support. Makes sense now. I'm going to try to re-apply some things and see what happens.
Movelifeup replied on at Permalink Reply
Well I must say I am impressed with what Miser has done for me. Thank you very much for this Phallanx, it's helped out a lot.
Phallanx replied on at Permalink Reply
Phallanx
@Movelifeup

Glad you got it all sorted in the end.
TheRealSean replied on at Permalink Reply
TheRealSean
Hi Phallanx(Great name also),

Thanks for the details regarding the license info.

I have been having a play with the miser on the site to see if it will improve the speeds.

I have noticed that if I turn off the cache (without miser) the site seems to speed up? nice bonus. Something 5.5/6 appear to have really made advancements in.

However when I enable miser the styling becomes a little jumbled up.

That is to say the 5.6 core css overrides my custom bootstrap css.

I had this issue once before when I loaded in the header after my custom css style-sheets.

Is there a way to prevent the default css from overriding the custom version? or do you think something else is at play.

Thanks
Sean
Phallanx replied on at Permalink Reply
Phallanx
@TheRealSean
PM me the site (without Miser enabled) and I'll take a look to see if there is anything miser will trip over.
ecomatt replied on at Permalink Reply
ecomatt
Hi i have miser 1.8.0 on my site and it looks like its conflicting with the base install of the slidehsow plugin?

here the site wi out miserhttp://bristolcityyoga.co.uk
heres the site with miserhttp://new.bristolcityyoga.co.uk...

on the home page you will see there is a default slideshow that onhttp://new.bristolcityyoga.co.uk... does not show up?

this site was having major issues before running 5.6.2 so iv but the site back to 5.2.1 and its running faster again.

can you have a look and see what you see?

also i would like to take the whole "compliance" as i dont really want it there. Do i need it by law?

Thanks for your help
Phallanx replied on at Permalink Reply
Phallanx
@ecomatt
What happens if you remove "Tony Popup"?
ecomatt replied on at Permalink Reply
ecomatt
i thought i had in the stack where it was but the stack never asked me to approve changes? so i just went into the stack and made another text edit and then approved changes and your right it works ok now. tonypopup was causing it to not show the slideshow.

if there a way to add a class of nocombine to get it to leave a script alone?

also can you comment on the need for the coockies or can i just delete the whole compliance folder and remove the coockies entry in the view.php

thanks for your help
Phallanx replied on at Permalink Reply
Phallanx
@ecomatt
Yup. You had the JS error even on the page where you were not using Miser and although everything seemed OK there, once Miser had moved things around it caused the problem.

There are various ways to control Misers behaviour by using defines in your site.php if you are not using the addon. You can tell Miser not to combine into a file, ignore, move things into the head rather than the footer and even remove completely. There is no "one-size-fits-all" for all scripts apart from the default which is fine for about 90% of intallations. If you search this page for "define(" you will find most of them (they are all documented in the readme, however).

There is a whole section (section 6) in the readme on cookie compliance. You do not need to delete anything, just add a define to turn it off.
ecomatt replied on at Permalink Reply
ecomatt
Sorry to ask but even after reading section 6 of the readme and reading over this thread looking for defines i can not get miser to ignore the AsmillerGallery 2 plugin on concrete5 version 5.5.2.1. could you please let me know what define i would need to put in to get it to ignore that particular plugin but keep working for the rest of the site. iv tried al sorts of things with no luck.

define('MISER_KEYS_IGNORE','jquery,asmillerGallery');
define('MISER_KEYS_IGNORE','jquery, asmillerGallery');
define('MISER_KEYS_IGNORE','jquery.js,asmillerGallery');
define('MISER_KEYS_IGNORE','jquery.js, asmillerGallery'); 
define('MISER_KEYS_IGNORE','jquery');
define('MISER_KEYS_IGNORE','jquery.js');


please tell me what configuration i need? none of the above work. i am probably using the incorrect handle for asmillerGallery or something.
Phallanx replied on at Permalink Reply
Phallanx
@ecomatt

Try this instead
define ('MISER_USE_CDNS',FALSE);
mnakalay replied on at Permalink Reply
mnakalay
Hello,
I just wanted to let you know about 2 problems I noticed with the latest miser (1.8)
1- the Javascript variables inserted by C5 appear twice when miser is enabled (var CCM_DISPATCHER_FILENAME, var CCM_CID, var CCM_EDIT_MODE...)
2- When submitting a website here on concrete5.org, it is not recognized as a C5 website if miser is enabled

Other than that, it definitely does the job.
Phallanx replied on at Permalink Reply
Phallanx
@mnakalay

1. Good catch. Whilst it doesn't affect site functionality, it'll be fixed in the next release.

2. Not a lot I can do about that apart from say turn off miser when submitting. It's more of an issue with their detection and only they know what that is.
mnakalay replied on at Permalink Reply
mnakalay
Wow you're fast.
for 2 that's what I assumed and did, I just thought you might want to add a warning in your help file or something.

Out of curiosity, how can I find out about the price and features of Miser as an add-on?
Phallanx replied on at Permalink Reply
Phallanx
@mnakalay

Send an email to the address in the readme and I'll send you the info pack.

Features: All of them.
mnakalay replied on at Permalink Reply
mnakalay
ok thanks i'll do that
Phallanx replied on at Permalink Reply
Phallanx
@mnakalay

OK For the JS duplication, here's the fix:

Change line 426 of Miser.php from:
$js_Top_Footer[] =  JSMin::minify( @implode('',$js_Top_Footer) );

to
$js_Top_Footer =  JSMin::minify( @implode('',$js_Top_Footer) );
mnakalay replied on at Permalink Reply
mnakalay
Thank you
MrGrowBizz replied on at Permalink Reply
MrGrowBizz
Phallanx: 2 issues I am having since upgrading to 5.6.0.2 and recent Miser update. 1. Adsense ads not visible (and block not editable) when Miser active 2. I Need to remove EU Cookie Compliance acceptance. Your assistance is greatly appreciated
MrGrowBizz replied on at Permalink Reply
MrGrowBizz
Sorry about that! Got my answer in the read me file. Thanks!
barkingtuna replied on at Permalink Reply
barkingtuna
I am working on launching another site and it has been plagued with load time issues so I decided to install Miser. Everything is fine until the view.php file is uploaded to the libraries directory. Here is the site in production without Miser http://www.tagpay.com/c5tag (miser is off, caching is currently on, and the view.php file is NOT in the libraries folder). It is built with 5.6.0.2.

When I add the view.php file, I lose my toolbar and mega-menu navigation. I also notice that the testimonials block in the footer displays all testimonials, versus the current setting of 1 at a time, and it overflows the div. I'm not sure if anything else is wonky as I promptly deleted the view.php file from libraries and everything went back to normal.

Is it safe to assume that I will need to make some exceptions (or whatever the term is) for mega-menu and testimonials? I am not an advanced developer, more a designer, but can follow thorough instructions quite well. Any help is greatly appreciated.
Phallanx replied on at Permalink Reply
Phallanx
@barkingtuna

You have a JavaScript error on your page (PIE.js?). Existing errors tend to get exacerbated by Miser so try fixing the error then applying Miser
barkingtuna replied on at Permalink Reply
barkingtuna
I fixed the PIE.js issue but it is running slow. I get better results with caching turned on it seems and no Miser. Index page load time with caching and no Miser is 1-1.5 seconds and with Miser it is 5-6 seconds. It is definitely doing something as the CSS is consolidated when I look at it through Firebug, but the YSlow report seems to conflict and says that the CSS and JS haven't. It is currently rated a C (75 score) and it was a D (68 score) prior to installing Miser with NO caching turned on. Can you glance at it and see what I might be missing?

http://www.tagpay.com/c5tag

Much Appreciated!

James
barkingtuna replied on at Permalink Reply
barkingtuna
I just turned caching back on with Miser and it is showing a 1.2 second page load time now and the same YSlow C (75 point) score.
Phallanx replied on at Permalink Reply
Phallanx
@barkingtuna
The first time you view a page when Miser is enabled it may well be a few seconds since it has to analyse the page, compress CSS and JS (the latter of which is very low) and save the result. After the first view it is mere milliseconds, however. If you view the page source, Miser will tell you how long it took to process (~41 ms by the looks of it).

So the problem was the javascript error? (Looks ok to me now)
barkingtuna replied on at Permalink Reply
barkingtuna
Well... all is well with the exception of the Testimonials block in the footer. It is a Global Area so it should be the same on each page. The block itself is set to display only 1 testimonial at a time and it does that on the home page. However, the Testimonial block overflows the footer/DIV still on every other page. It is the only thing acting up it seems.

http://www.tagpay.com/c5tag (Home Page with correct footer)
http://www.tagpay.com/c5tag/index.php/business-solutions/... (example of another page where footer has issue)

The site is still in production but we look to launch in the next few days.

Much Appreciated,

James
Phallanx replied on at Permalink Reply
Phallanx
Does it show correctly if you remove
http://w.sharethis.com/button/buttons.js

(share this addon?)


I can also see the JS error
[quote]
Uncaught Error: Syntax error, unrecognized expression: options.speed)});};}
[/quote]

Also. On you index page you have an error
ncaught Error: NOT_FOUND_ERR: DOM Exception 8


Both of these errors are usually caused by errors in CSS that are being referenced by javascript where the tag doesn't exist (typo).
barkingtuna replied on at Permalink Reply
barkingtuna
I take that back... Problog Sharethis in page list is not working either and it throwing an error. The Sharethis key is correct and added in Problog settings.
Phallanx replied on at Permalink Reply
Phallanx
@barkingtuna
Problog is a paid add-on, therefore I cannot install it to try and troubleshoot to find settings that might make it work.

However. The button.js has an http url so I suspect (and its just a guess) it may down to an ordering issue as Miser ignores urls with http.

Maybe Chad Strat can provide a clue?
agile replied on at Permalink Reply 2 Attachments
agile
Hi Phallanx,

I've recently installed Miser 1.8.0 and have found a great improvement in speed, thank you, but have a small issue with it not displaying the correct customized colours.

I'm using the chameleon theme (which is great for styling) but have a few things such as navigation bar colour, footer font, feature box colour, etc that Miser has effected.

I've attached two screenshots, one of the theme customization page and one of the new home page.

Any idea of a quick fix?

Thanks

Alex
Phallanx replied on at Permalink Reply
Phallanx
@agile
Do you have the Concrete5 cache enabled?
agile replied on at Permalink Reply
agile
Yes, I have switched on full page caching, overrides and basic.

I tries it before switching them on and then switched them on and cleared the cache, etc and no change.
Phallanx replied on at Permalink Reply
Phallanx
@agile
Turn off all the caching, delete all files in the [root]/files/cache directory and do not turn back on.
agile replied on at Permalink Reply
agile
Before I installed Miser I turned all caching off and deleted the cache from the dashboard. Happy to try again.

When you say "delete all files in [root]/files/cache" do you mean all folders, images and everything in there? or just all text files?

Sorry, not a pro, still learning

Thanks
Phallanx replied on at Permalink Reply
Phallanx
@agile
Everything including the css and js directories. Any files that are required will be regenerated including images).
agile replied on at Permalink Reply
agile
Ok done that. Cache all turned off and all cache files deleted
agile replied on at Permalink Reply
agile
Website still showing old/incorrect colours, etc
Phallanx replied on at Permalink Reply
Phallanx
@agile
[quote=Shotster]
If I recall correctly, in order to preview changes when customizing a theme through the dashboard UI, the C5 cache must be enabled. IOW, the preview relies on the cache.

It's unfortunate, but I'm pretty sure that's the case.
[/quote]
I knew I had heard of this before........

I suggest turn on the cache, disable Miser by renaming the view.php, make your changes then rename view,php back.
agile replied on at Permalink Reply
agile
The problem isn't in viewing changes when customizing a theme through the dashboard UI, that preview is totally correct, the problem is that the live site is not showing what I am seeing on the preview of the customized theme.

The two were perfectly aligned before I installed Miser.
Phallanx replied on at Permalink Reply
Phallanx
@agile
Yes. Miser needs to have the cache off, but the editor needs it on. It was discussed earlier in the thread.

Saying that. I put in a change that enabled miser to use the cache and was unable to replicate it after that (so assumed it worked)
Phallanx replied on at Permalink Reply
Phallanx
OK. I'm guessing that your theme uses
$this->getStyleSheet('main.css');
$this->getStyleSheet('typography.css');


Use the "$this->getThemePath()" instead
$this->getThemePath().'main.css'
$this->getThemePath().'typography.css'


See if that helps ;)
agile replied on at Permalink Reply
agile
Thanks Phallanx,

The only place I could find those lines were in the header.php of the chameleon theme elements files. I changed them but it threw the styling out completely.

Am I changing files in the wrong place?

Your help is much appreciated...
Phallanx replied on at Permalink Reply
Phallanx
@@agile
It sounds like the right place, but just replacing the path shouldn't make a difference. Is the styling "different" without Miser?

I looked in the marketplace for your theme, however it is a paid add-on so I will not be able to download and test.
agile replied on at Permalink Reply 2 Attachments
agile
Yes, without Miser, the styling is as per the attached file (with a yellow header) with Miser the header is grey (and a few other things are altered).

I've attached a file with the code from the chameleon header.php file for you.
Phallanx replied on at Permalink Reply
Phallanx
@agile
The file you sent shows the css links as
<link rel="stylesheet" media="screen" type="text/css" href="<?php   echo $this->getStyleSheet('main.css')?>" />
   <link rel="stylesheet" media="screen" type="text/css" href="<?php   echo $this->getStyleSheet('typography.css')?>" />


What I meant was. When you change the paths to getThemePath" (without Miser). Is the theme styling "thrown" or only when you then apply Miser?
agile replied on at Permalink Reply
agile
Just to check before I do this, I would amend these lines

From:

... echo $this->getStyleSheet('main.css')?>" />
... echo $this->getStyleSheet('typography.css')?>" />

To:

... echo $this->getThemePath().'main.css'?>" />
... echo $this->getThemePath().'typography.css'?>" />

ie: with the ?" etc?
Phallanx replied on at Permalink Reply
Phallanx
@agile
Yes.

Copy the current header.php (so that you can just switch back if anything goes wrong) and change those lines. You can just cut&paste the examples I showed to you in the earlier post.

The "?" is actually part of the php syntax (<?php .... ?>). It might just be easier to change the color value in the main.css though.
agile replied on at Permalink Reply
agile
Right. Deleted Miser and did the changes to the header.php above and the styling broke in the same way
Phallanx replied on at Permalink Reply
Phallanx
@agile.
OK. That confirms that using the previous method modifies the css "on-the-fly" and, from my own investigations, using the styling editor doesn't modify the css file (which is what Miser uses if it optimises).

So for your theme, if you want to use the admin styler you must use the "GetStyleSheet" otherwise it ignores your changes. The problem for Miser is that this method produces a an HTTP URL which won't get optimised and is left at the top of the page. Most of the time this is fine, but it looks like your theme relies on the position of that url within the page so that it overrides some other setting set by something else.

The upshot is that using that theme with Miser means that the admin styler is ineffective (since the changes are never saved to file and therefore styling order is not preserved) so the only solutions at present are to edit the CSS directly so that Miser can pick up the changes or not use Miser and be able to use the admin styler.
agile replied on at Permalink Reply
agile
Ok, thanks.

Will decide what to do next then.
MrGrowBizz replied on at Permalink Reply
MrGrowBizz
Phallanx, Could you please take a look at AlphaHD.com. I upgraded to 6.6.02 last week along with the latest version of Miser. I have temporarily opened to guest so you can view, but need to go live next week as the related business is opening the following week. As we discussed in the past, understand the need for the package for a commercial site.

The issue is I have lost up to 4 seconds. I had it down to load times averaging 3-3.5 seconds and now it goes from 6-8. The time difference appears to be all in "wait time". Was wondering if you could check to see if Miser appears to be working properly. Thanks, Tim
Phallanx replied on at Permalink Reply
Phallanx
@MrGrowBizz
In your last email dated 18/01/2012 you refused to use the payment method for purchasing a commercial waiver after I spent a lot of time optimising your site (not all of it to do with Miser).

I suggest you uninstall Miser (since you don't have a waiver) and put in an support request to the Concrete5 team.
MrGrowBizz replied on at Permalink Reply
MrGrowBizz
Phallanx, Sorry for the misunderstanding, as you can see by the site it has not been live until I opened it up for you to view. It was not intended to go live until the brick and mortar side of the business was ready, which has taken far longer than I thought. If fact had not touched the site for about 7 months until a week ago. Since it was not being used, why would I have purchased the waiver? I always had full intentions of purchasing when I was ready, which is now. I did appreciate your time spent a while back. I wish you would have gotten of hold of me and discussed, as I would have been happy to pay you for your time spent, versus buying the waiver, or telling me I needed to regardless in exchange. The C5 team offered no support when I needed it, and you helped. The real issue with the site back then was an indexing error causing slow queries which was fixed and then confirmed by the C5 team it was an issue. Please contact me by email so we can discuss and hopefully resolve any harm done.
ProjbyP replied on at Permalink Reply
ProjbyP
I am just reading about Miser in the threads and no where could I find the How To? Is it really as simple as just adding the view.php file? If so, where do you add the file? Does it replace other "view.php" files?

Why isn't it part of the core? Wouldn't that make life much easier?

Interested in speeding up the sites I manage and this looks like a great solution!

Thanks in advance for your help.
Phallanx replied on at Permalink Reply
Phallanx
@PeggyShields
There is a readme that explains installation (amongst other things) included in the download. It's very straight forward.

There is an add-on which makes life a lot easier. However that comes at a cost and is primarily the value-added component of the commercial usage waiver.
ProjbyP replied on at Permalink Reply
ProjbyP
I can't seem to find the Add-On - I was looking for it.
Phallanx replied on at Permalink Reply
Phallanx
@PeggyShields
It's sent along with the waiver so you will not find it in the market place (if that is where you are looking).
ProjbyP replied on at Permalink Reply
ProjbyP
Thanks so much! I will see what I can do with it. :-)
Steevb replied on at Permalink Reply
Steevb
Tried miser on two C5 sites, one community and one commercial.

Cannot use miser on either due to CSS being messed up with IE8, basically certain rules and images missing.

Tried with and without the .htaccess mods, 'getthemepath' verses 'getstylesheet'.

Couldn't find any reference to the problem after searching.

Is this a normal reaction?
Phallanx replied on at Permalink Reply
Phallanx
@55webdesign
If it is only internet explorer then it's probably because you are using conditional CSS statements (e.g <!--[if IE 8]>).

Miser moves all conditional CSS statements to the end of the HEAD (and doesn't include them in the optimisation) since the general use case is for them to override previous CSS. If you are relying on a conditional CSS to be in the middle of other CSS, then the other CSS will get optimised and placed in a file and loaded before the conditional one.
Steevb replied on at Permalink Reply
Steevb
This is what I use for IE.

<?php    defined('C5_EXECUTE') or die(_("Access Denied.")); ?>
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">


No conditional statements per se

Might try removing the 'if' bits and see 'if' that helps, no pun intended.

Thanks

Steev
Phallanx replied on at Permalink Reply
Phallanx
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

Move that code to before the others instead of after?
mnakalay replied on at Permalink Reply
mnakalay
Hello,
@phallanx: I think moving that bit before the rest will make it to appear before the <html> tag while it's supposed to be in the head, so the might be a pro blem, but not sure.

@55webdesign: the first thing you have to do is check if, with miser on and using ie8, you have the correct html with the correct classes active. That wil help you start to pinpoint your problem.

On possibility is that the first 3 conditional comments are built to show the html tag with the proper classes only for specific versions of IE. The last one on the other hand is built to show the html tag for any browser superior to ie8 or not ie using nested if statements. Maybe that's what is messing miser up?
Phallanx replied on at Permalink Reply
Phallanx
@mnakalay
Indeed.
This looks like javacript voodoo to me or, at best, abusing selector behaviour.

If the idea is that the HTML tags contain replaceable tags that are decided at run-time; then it won't work since Miser will always move them to before </head> and you will end up with the opening html tag in the middle of your head (instead of at the very beginning). If that happens, I'm not sure what the browser would make of it.

I'll have to find a free theme that uses this technique and see whats going on.
mnakalay replied on at Permalink Reply
mnakalay
Actually that's a technique that's used by Paul Irish's HTML5 boilerplate so it's pretty common and well used but of course it was not designed with runtime re-arranging in mind.

The boilerplate was ported to a free C5 theme. The lines you need to check are in elements/header.
The class names are a bit different, other than that it's exactly the same principle.

Here's the link:
http://www.concrete5.org/marketplace/themes/theme-blank-html5-boile...

Good luck
Phallanx replied on at Permalink Reply
Phallanx
@mnakalay
I can only check in ie9 but everything "looks" fine.
Miser leaves it all at the top since there is no link between the selectors (more luck than design I think).

Must be something else going on.
admin replied on at Permalink Reply
I should mention that I've been using this technique on my site to target IE for 1-2 years now with Miser enabled.


http://adamjohnsondesign.com is the site.
Phallanx replied on at Permalink Reply
Phallanx
@adamjhohnson
Thanks Adam.
I can see that the "funny" stuff is indeed ignored whilst "html5shim" (being a link) is sorted to the end as it should be.

My regex-fu is better than I thought.lol
mnakalay replied on at Permalink Reply
mnakalay
So I tested with ie6, ie7, and ie8 and it all works as expected.
The only problem I had is with some javascript that got messed up by concatenating and css was not loaded by the browser. Once I sorted that out, absolutely no problem with IE conditional comments.
mnakalay replied on at Permalink Reply
mnakalay
I just found a funny bug. Well it's not a bug, I suppose it's more a regex being a bit too optimistic.

Apparently, if any external javascript file happens to have the word "jquery" in its file name and Miser is configured to load jquery from cdn, that file will be removed as well.

I had a script called touchtouch.jquery.js and miser just took it out.

I think maybe the regex should be less permissive, especially since C5 jquery always has the same file name whatever version it is (I think)
Phallanx replied on at Permalink Reply
Phallanx
@mnakalay
That flies in the face of jquery naming conventions (generally rather than explicitly)which is usually

jquery.SOMETHING.js or
jquery.SOMETHING.min.js.

But you can override the default search patterns with a define for these scenarios (e.g. with "/jquery.js").

But good to know it's all fine for the CSS selectors.
Many thanks for checking it out.
mnakalay replied on at Permalink Reply
mnakalay
actually, I just renamed the file as there was no real good reason to keep the "jquery" in the file name
mnakalay replied on at Permalink Reply
mnakalay
@Phallanx: I'm going to check in ie8 and let you know

@adamjohnson: did you notice that your conditional comments don't actually deal with ie8 as instead of [if IE8] you have [if IE]?
Steevb replied on at Permalink Reply
Steevb
I've spent all morning trying to work out how to get IE to play with miser.

My compromise was to remove all IE head reference, as in my previous post.

Added
<!--[if  IE ]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->

To stop javascript errors popping up.

Now IE8 looks like it normally would, without any of my rounded corners or drop shadows.

Whereas without miser It renders the above styles.

I'm willing to let this go as the website will only get bigger and needs to be as fast as possible.

Page speed is now 96, was 68. There are further tweaks to be made, but a vast improvement.

The modified (community) site in question is :http://thundridge-wadesmill.co.uk/...

The other site (commercial) which I haven't modified yet is:http://blackdoggames.co.uk/

For me with IE8 the commercial site has all my styles in place. Will need to think a bit more on how to compromise before I change it.


@Adam, you show javascript errors for me with IE8 (merge.js).
mnakalay replied on at Permalink Reply
mnakalay
Hi,
something I don't understand is that your html tag is supposed to get class names specific to different versions of IE. In case of IE8 it will get a class name of "lt-ie9"

But when I look in your css files (on both sites) you don't have any style set to apply specifically to those classes. How then do you expect IE8 (or any other version) to be served anything different than what the other browsers are getting? Am I missing something?
Steevb replied on at Permalink Reply
Steevb
I used to run different conditional statements and use extra css files to compensate for IE, which I hated.

Over time and through research and testing I found the 'X-UA-Compatible' tag, although not compliant, works for all my sites.

But now the time has come to speed up C5, so I tried using miser (can't use varnish on my servers).

Fantastic tool, not sure what miser did, but it messed up the css (for IE).

Anyway, this afternoon after more research and experimenting I have put the 'X-UA-Compatible' in my .htaccess file and now it seems we're back on track.

You could say why didn't you use .htaccess earlier, I have done several times but the variations I tried never worked.


Now it seems the code I found below is working.

<FilesMatch "\.(htm|html|php)$">
    <IfModule mod_headers.c>
        Header set X-UA-Compatible "IE=Edge, chrome=1"
    </IfModule>
</FilesMatch>


Perhaps you could try it and let me if it works for you.

Steev
Phallanx replied on at Permalink Reply
Phallanx
@mnakaly
Hmm. This strikes me as odd too (I checked after you mentioned it).

This person also had issues. It boiled down to the tags not matching the CSS which, of course, they must.
http://stackoverflow.com/questions/10919480/html5boilerplate-ie-con...

There are a lot of complicated rules for IE falling back/forward to different rendering engines. I wonder if it is just "fortunate" that the "X-UA-Compatible" declaration works in some of these scenarios without the proper CSS?.

@55webdesign
Anyway.
Glad you have a working solution
mnakalay replied on at Permalink Reply
mnakalay
Well actually in this case it's different because his x-ua-compatible tag uses "chrome=1" so it doesn't need any specific css. It offers to install Chrome Frame which is a plugin for ie6, ie7, and ie8. Google defines Chrome frame as follow:

Google Chrome Frame is an open source browser plug-in. Users who have the plug-in installed have access to Google Chrome's open web technologies and speedy JavaScript engine when they open pages in the browser.

Google Chrome Frame seamlessly enhances your browsing experience in Internet Explorer. It displays Google Chrome Frame enabled sites using Google Chrome’s rendering technology, giving you access to the latest HTML5 features as well as Google Chrome’s performance and security features without in any way interrupting your usual browser usage.

When Google Chrome Frame is installed, the web just gets better without you having to think about it.
Phallanx replied on at Permalink Reply
Phallanx
@mnakalay
Thanks for the detailed explanation.

Just glad I'm not a web developer.
Steevb replied on at Permalink Reply
Steevb
@Phallanx
"I wonder if it is just "fortunate" that the "X-UA-Compatible" declaration works in some of these scenarios without the proper CSS?."

Proper CSS, excuse me?

A lot of people spend more time than they should pandering to IE, it is not 'fortunate', it is 'thankful' that something is easy to work with?

BTW, the 'stackoverflow' issue is irrelevant to mine.

@mnakalay
"Well actually in this case it's different because his x-ua-compatible tag uses "chrome=1" so it doesn't need any specific css. It offers to install Chrome Frame which is a plugin for ie6, ie7, and ie8."

One reason I use it.

Anyway, I found don't need the 'shim' either!

Happy days, less code, less IE worries.
mnakalay replied on at Permalink Reply
mnakalay
@Phallanx: you're welcome and I totally understand your feeling :)
Phallanx replied on at Permalink Reply
Phallanx
Miser 1.8.1 has just been released as of 09/12/2012

The update includes a minor bug fix and a change to the CSS regex to capture CSS links with the rel=stylesheet after the link which, previously, were not included in the optimisation.
Highlight replied on at Permalink Reply
Hi. i have tried this and it marge the js and css files fine. But all my styles is not applied on my link, divs, h tag etc..

When i click show strukture on my page an navigate in the the marge css all the styles is in there.

Eny ideas how i can solved this problem ?
Phallanx replied on at Permalink Reply
Phallanx
@Highlght
Difficult to say without seeing the site.
Highlight replied on at Permalink Reply 1 Attachment
Unfortunately i can't show you becuse i run on localhost..

Maby this screenshot can help ?
It's like it load all the styles but dont apply them.
Phallanx replied on at Permalink Reply
Phallanx
@Highlight
Nope. I would need to see the page source and trace the links.
Did you disable cache?
Highlight replied on at Permalink Reply
Yes..

Ok, i have found out that it has somthing tto do whit @media print { } in css. If i remove this, and its styles it works.. Hmm wierd !
Phallanx replied on at Permalink Reply
Phallanx
@Highlight
I cannot think of a good reason why that should be the case. Miser doesn't really care about @media declarations.

Glad you got to the bottom of it though.
Let us know how you get on.
Highlight replied on at Permalink Reply
Oh. I have just read the licens and notic that i can not use it for commercial purposes.. So i have to let it go.. To bad, becuse it's doing a relly good job.. Is there eny way to get permission to use it commercial?
Phallanx replied on at Permalink Reply
Phallanx
@Highlight
It's not free for commercial purposes. You have to buy the waiver (which also gives you the Concrete5 add-on).

If you are interested, email me at the address in the Miser readme and I'll send the info pack.
TheRealSean replied on at Permalink Reply
TheRealSean
Hi Phallanx,

I currently have a client who has mentioned he would like to decrease the amount of js and css calls on his site.

I thought Miser would be a great choice for this but upon adding the view I get the following error
Fatal error: Call to undefined method Page::supportsPageCache() in /var/www/vhosts/mysite.com/httpdocs/libraries/view.php on line 728


I had turned off cache and cleared this out, I am running this site from the updates folder version currently using (5.6.1b4).

Do you have any ideas what could be causing this or how I can get around this?

edit: I have added the miser support files, as mentioned in the readme and added what I believe to be the correct view for the version.

Thanks
Sean
Phallanx replied on at Permalink Reply
Phallanx
@TheRealSean
I take it you are not using the addon?

Without the addon, you need the modified view.php of the current core for 5.6.1. The new release (1.8.2) which has it is in the sourceforge repository (so you can download it) but I am waiting for the core team to release the update through the dashboard before I zip it up for release (just in case they make changes).
TheRealSean replied on at Permalink Reply
TheRealSean
@Phallanx,
I am not using the addon, I am attempting to use the version found on sourceforge with the modified view for 5.6.x which was placed in my top level libraries folder.

Is there meant to be a 5.6.1 folder? (I'm currently using miser 1.8.1 downloaded yesterday)

Is it possible that its because I am using the beta version of the 5.6.1b4 release? currently I have not updated to the full 5.6.1 as the automatic update is not picking up the new version
Phallanx replied on at Permalink Reply
Phallanx
@TheRealSean
Yes. Like I said. Miser 1.8.2 (which has the view for Concrete5.6.1) hasn't been released yet. But you can download it from the repo
http://miser.svn.sourceforge.net/...
TheRealSean replied on at Permalink Reply
TheRealSean
Sorry, I missed the 1.8.2 part, I was looking at the actual sourcepage miser page not the repo, I gave it a go and the new view, works great.

With the package addon is it possible to remove the cookie banner that appears?

Thanks
Phallanx replied on at Permalink Reply
Phallanx
@TheRealSean
Yes. But you can also turn it off by adding the following define to your site.php
define('MISER_EU_COOKIE','');
pawelg replied on at Permalink Reply
I have a strange issue with a misser. I have installed it correctly I think. My site (concrete 5.6.0.2) is loading much faster (cache is disabled). But there is one big problem: I can not log in as a different user than the super user.

On super user everything is fine, but on different user, just after login I can see white stripe on top, but there is no edit bar (no buttons). I can not access dashboard also. It looks, like the session on web browser is not written. Any suggestion?

The only one package I have installed on that site is gallery block. That's all.
Phallanx replied on at Permalink Reply
Phallanx
@pawelg
Do you have a JS error?

Try adding the following to your site.php
define('MISER_EU_COOKIE','');


What is the site address?
pawelg replied on at Permalink Reply
@Phallanx
I spent 2 days to solve that problem and finally, thanks to you it works fine!!!
Thank you so much!
Phallanx replied on at Permalink Reply
Phallanx
@pawelg

Glad you got it sorted.
Phallanx replied on at Permalink Reply
Phallanx
Miser 1.8.2 has been released as of 21/3/2013.

This release supplies the view.php for Concrete5 versions 5.6.1.0 and 5.6.1.1

The only other change is to include the jquery 1.7.2 CDN for concrete5 5.6.1.x

Users of the addon are recommended to update the Miser core in
packages\miser_optimiser\helpers to the new version by overwriting with the files contained in 1.8.2
Phallanx replied on at Permalink Reply
Phallanx
Sheesh!
Having just released Miser 1.8.2 to support 5.6.1.1, within a couple of days 5.6.1.2 is deployed.

For the non-addon users. Please use the view.php in the 5.6.1.1 directory. No changes to Miser are required to support 5.6.1.2 and the view.php is identical to that of 5.6.1.1.
clairec replied on at Permalink Reply
clairec
Hi Phallanex, have you had any instances where Jquery has been stripped out on a site that's not in editing mode? Editing mode it loads fine I'm a little perplexed on this.
I put a post up this morning here on a new thread but think it may be a miser issue, maybe wrong however could you provide any insight?
Here's my other posthttp://www.concrete5.org/index.php?cID=469566....
Cheers!
Phallanx replied on at Permalink Reply
Phallanx
@clairec
I have not had any reports.

If Jquery isn't in the original source, Miser won't put it in. (Clear cache, yada, yada)

Can you turn off Miser so that I can see the origial source?

Phallanx
clairec replied on at Permalink Reply
clairec
Thankyou for the quick response!
Yeah already cleared cache quite a few times.
Whats the best way to turn off miser? simply removing it brings up errors
clairec replied on at Permalink Reply
clairec
For some reason this is not displaying in core elements/header_required.php
$this->addHeaderItem($html->javascript('jquery.js'), 'CORE');

but if I remove it from there and place it in elements/header.php on the theme it works that's very strange
clairec replied on at Permalink Reply
clairec
Ahhh spoke too soon it only works on the home page
mnakalay replied on at Permalink Reply
mnakalay
Hi there, check my answer in your original threadhttp://www.concrete5.org/index.php?cID=469566...
Phallanx replied on at Permalink Reply
Phallanx
You can turn off Miser by renaming the view.php in [root]/libraries/ (to anything else).

If Miser was stripping out the jquery, then I wouldn't expect you to be able to have it on some pages but not others just by playing around with the addHeaderItem. It seems to point to the jquery not being there in the first place.
pawelg replied on at Permalink Reply
I have another issue with miser. But it is more the server issue I think.

I have concrete 5.6.1.2, and there is no problem with the miser on many servers, but on one of them (nazwa.pl - it is not a bad server) miser can not create the merged files. CHMOD on cache direcotry and subfolders is 0777, like always. Is there anything I have to remember? Any other directory should have 0777 or something?
And the last question: how can I check some error logs from miser?

My firebug console just shows me, that there is 404 error, no merged file (with path to it like files/cache/css/longname_merged.css and the same for js merged file)
Phallanx replied on at Permalink Reply
Phallanx
@pawelg
Well. There is a cache file also created in the miser_support directory for the CDNs, but this does not usually cause much of a problem. Try CHMOD on miser_support and see if that helps.

There is no log file specifically for Miser. If Miser cannot write a file, it will be shown in the normal error logs.
pawelg replied on at Permalink Reply
Thanks for your reply, but CHMOD on miser_support did not help.

But finally I have a solution that I have read on on this thread.
Fix is in helpers/miser_support/miser_bridge_C5.php file paste that line just before the "if" part. I don't know why, but it helps

$this->set_root(DIR_BASE);
Phallanx replied on at Permalink Reply
Phallanx
@pawelg
That command was added specifically for windows machines which, when certain php settings were in place, didn't set the document root or had discrepancies.

It is very rarely needed (you are only the second person in 2 years), but usually you can tell if it is by just printing the document root. If it's empty or doesn't point to the server root, then it needs adding.


Glad you got it sorted!
lackadaize replied on at Permalink Reply
lackadaize
I'm on an iis server and I have the following error at the top of my page:

Warning: $_SERVER["DOCUMENT_ROOT"] Not Set Or Invalid - The path to the document root must be set using the set_root() method. in D:\webs\newe910002\helpers\miser.php on line 824

I"m unsure how to set the root using "set_root() method. I've tried doing what I thought it should be but had no luck. This site is live and I dunno what to do at the moment. When I remove the miser files the whole site goes blank and I don't want to spend 30min FTP-ing the files back on with a dead site.

Please help anyone that can.

site is athttp://www.eclinicalsol.com
lackadaize replied on at Permalink Reply
lackadaize
This only seems to be happening on pages other than the homepage. I don't understand what's going on.
lackadaize replied on at Permalink Reply
lackadaize
I take this back. It happens randomly on some page loads, and not on others.
Phallanx replied on at Permalink Reply
Phallanx
@lackadaiz
The warning is indicating (and suggesting the solution to) an issue with a particular configuration of IIS and is documented (with what to do) earlier in this thread

http://www.concrete5.org/community/forums/customizing_c5/miser-web-...

Add it under the comment line
//Cache Directories

If you want to disable miser. You only need to rename or remove the file you copied into libraries (rename view.php to -view.php for example).

The reason you have the errors after "deleting the files" is because you only removed the files in the helper directory but left the one in the libraries directory.
lackadaize replied on at Permalink Reply
lackadaize
changing the name didn't work. Ended up with a completely blank site. But I'm hoping to make the fix anyways. Where in miser_bridge_c5.php would I insert $this->set_root(DIR_BASE); ? I have very little knowledge of php so I don't know if the placement matters (I'm assuming it would).
Phallanx replied on at Permalink Reply
Phallanx
@lackadaize
Add it under the comment line
//Cache Directories

Although it doesn't really matter.

If it is still blank after renaming. Then presumably you have the cache active. You need to clear the cache.
lackadaize replied on at Permalink Reply
lackadaize
It isn't blank anymore, but it's still returning the same error code =

Warning: $_SERVER["DOCUMENT_ROOT"] Not Set Or Invalid - The path to the document root must be set using the set_root() method. in D:\webs\newe910002\helpers\miser.php on line 824

Just to be clear you want this line of code letter for letter? :

$this->set_root(DIR_BASE);

thanks for all the help.
Phallanx replied on at Permalink Reply
Phallanx
@@lackadaize
Yes. Exactly that. You will get a pars error if it is not correct.

Turn off and clear your cache.
lackadaize replied on at Permalink Reply
lackadaize
I did all that you said just now and I still get the same error. I'm sorry but I'm at a loss.
lackadaize replied on at Permalink Reply
lackadaize
but again, it works in IE for the homepage and randomly on some others. Also in Chrome sometimes it works. Not in Firefox or Opera though. Why would that make a difference?
lackadaize replied on at Permalink Reply
lackadaize
Now it works most of the time in Opera on all pages, homepage works in IE and Chrome, and a few pages in Firefox? I'm gonna clear the cache again and see if that fixes it.
lackadaize replied on at Permalink Reply
lackadaize
turned off and cleared the cache again and now it won't work on any browser without the error.
Phallanx replied on at Permalink Reply
Phallanx
with the warning. Miser won't optimise
Is D:\webs\newe910002 actually where the root is?
lackadaize replied on at Permalink Reply
lackadaize
the html file is /newe91002 . That should be the root. this file was set up by the server administrator and is contained in /webs I haven't had any other problems with the site til now though so I'm suprised that there would be any kind of issues with the root folder.
lackadaize replied on at Permalink Reply
lackadaize
I cleared my Chrome cache and the error goes away completely, but I don't believe miser is doing anything as the css/html/js isn't minified. I've tried this on my test site and it worked fine, minified and all, but the iis server on this site is just giving me problems.
Phallanx replied on at Permalink Reply
Phallanx
newe91002 is a file? Not a directory?
lackadaize replied on at Permalink Reply
lackadaize
when I ftp in that's the file I see. I believe it's the http docs file as I haven't had any problems with the site til adding miser, and it's been hosted for about a month. Just went live about a week ago.
lackadaize replied on at Permalink Reply
lackadaize
actually no, sorry. It's a directory. It's just the folder that I'm supposed to put my site files in.
Phallanx replied on at Permalink Reply
Phallanx
So if you "enter" that file (double click or whatever you need to do in your FTP client) what do you then see?
lackadaize replied on at Permalink Reply
lackadaize
all the concrete files =

blocks, concrete, config, controllers, css, etc. (and it's the upper level of them, so all the core files are still contained in /newe910002/concrete/concrete/
Phallanx replied on at Permalink Reply
Phallanx
OK. I think we posted simultaneously.

It is definitely a path problem. So try this.

Remove the entry you added in miser_bridge_C5.php
$this->set_root(DIR_BASE);

On line 333 of Miser.php. Comment out
if (!$this->check_root()) return $html;

i.e replace with
//if (!$this->check_root()) return $html;
lackadaize replied on at Permalink Reply
lackadaize
I did that, turned off and cleared cache and it's still got the error. However, when I run diagnostics it shows that css/html/js are being minified so miser is at least taking effect. Also went back and turned full page caching back on and it was the same result.
lackadaize replied on at Permalink Reply
lackadaize
however, the error doesn't seem to show up in firefox or chrome. Shows up in IE and Opera
Phallanx replied on at Permalink Reply
Phallanx
You cannot get the warning because we just disabled it. If you are still seeing it, it must be in your browsers cache since I'm trundling around your site now and it looks fine.
lackadaize replied on at Permalink Reply
lackadaize
yeah that did it. Thanks a bunch. I still have load times in the 4s range, but it seems to be working when I run GTmetrics. I wish I could enable gzip compression cause it seems to be the only thing holding the site back from running smoothly. Thanks a million for all the help. This just ruined my Friday night. I'm getting a drink. :)
lackadaize replied on at Permalink Reply
lackadaize
The following symbol is showing up in the footer and at random parts of my site now: ļæ½

This only happened after I made these changes. It doesn't show up in firefox. Any ideas? This is all so bizarre. I don't have any of these problems on my test site...http://www.nomad-sites.com
Phallanx replied on at Permalink Reply
Phallanx
The characters are typical of an encoding problem and google is awash with IIs issues about weird characters, especially when developing on Apache and then moving to IIs or using text editors with ASCII vs UTF8 encoding schemes.

The good news is that it only seems to affect bullet lists so it *could* be as simple as defining utf8 in the css files or specifying a character encoding in your editor.

http://stackoverflow.com/questions/2526033/why-specify-charset-utf-...

Beyond that, I don't know. I have little experience with Windows IIS to advise further.
lackadaize replied on at Permalink Reply
lackadaize
seems like everything is set to utf8_general_ci everywhere I've looked. I just went through and got rid of unnecessary spaces and created my own bullet graphics to get by the funky characters rendering funny in Chrome and IE. Thanks again Phallanx for all the help. :)
lackadaize replied on at Permalink Reply
lackadaize
Do you know, is it possible to gzip the merged css and js files after minifying them with miser?
Phallanx replied on at Permalink Reply
Phallanx
For what purpose?
Sending zipped content is the perview of the server (mime types, headers etc). If you want to send zipped content from a server where zipped content isn't turned on, then you need to use a php file that zips it up and sends the headers etc AND make an entry in the htaccess to intercept requests to use your php file (assuming they have also prevented you from changing the php.ini).

http://ardamis.com/2010/07/11/compress-files-without-mod_gzip-or-mo...

It's not something Miser should be concerned with.
It's much easier just to enable transparent compression on the server.
lackadaize replied on at Permalink Reply
lackadaize
point taken. thank you.
pixel8 replied on at Permalink Reply
pixel8
Hi,


I would like to know where to configure miser.. can you help with that.. I don't know which file I can put in the custom configuration? :-(

I tried in config/site.php, but that caused an error.. after that I tried the header in my theme.. this seems to disable miser totally.. :-(

What I want is to leave superfish untouched so that it does not get merged.. but I don't know where to configure this? :-(

Any help is appreciated!
Phallanx replied on at Permalink Reply
Phallanx
@pixel8
The site.php is the correct place to modify Misers behaviour. If you are getting an error then it is probably a typo.

There are a couple of options to exclude a file and which one you use will depend on why you want to exclude it. Probably the easiest is to make Miser not combine it using
define('MISER_KEYS_IGNORE','myfile1,myfile2,myfile3');

Miser will still sort it to the end of the page, but will not combine or minify it into the merged file.

If you use
define( 'MISER_KEYS_IGNORE','myfile1,myfile2,myfile3' );

Then Miser will ignore it completely leaving it wherever it is in the page. Be careful of dependencies though since if the file depends on, say jquery, you will also have to ignore that too.
pixel8 replied on at Permalink Reply
pixel8
thank you very much..! is there a list of available commands somewhere? I tried using the commands from the readme file, which doesn't look like the define commands? :-)

by the way, on the Miser Sourgeforce site it appears from a screenshot that an addon for concrete5 exist for miser where the configurations are available from the dashboard? (Miser Concrete5 Commercial Addon) Can't seem to find it in the marketplace - is it possible to buy somewhere? and is Miser supported for the newest concrete5 although it is not on the list in Miser readme?

Thank you in advance :-)
Phallanx replied on at Permalink Reply
Phallanx
@pixel8
There is a list of the defines at the end of section 5 of the readme.

The addon isn't in the market place; the core team wouldn't allow it. If you want the addon, then email me at the email address at the top of the readme and I'll send the details (pricing etc).

Miser doesn't officially support any new versions until a couple of days after the core team release the new version and push out via the dashboard. At that point, Miser is tested against the new CC5 version and a new view.php is generated if required.
Generally, if you use the addon, then it usually works without having to wait since it doesn't need the view.php. Still. Official support will only start once it has been released via the dashboard as that is the point at which CC5 is considered "stable".
lackadaize replied on at Permalink Reply
lackadaize
migrated the same site as before and I'm seeing the following error at the top of the screen.

Warning: unlink(/home/eclinicalsol/www/eclinicalsol.exstream.tv/helpers/miser_support/CDNS_cache.txt) [function.unlink]: Permission denied in /home/eclinicalsol/www/eclinicalsol.exstream.tv/helpers/miser_support/miser_CDNS.php on line 105

tried to delete miser altogether but ended up with a blank screen again. Also tried renaming site.php with the same result.

Any ideas?

thanks
lackadaize replied on at Permalink Reply
lackadaize
I ended up commenting out line 105 in miser_CDNS.php altogether and the error disappeared. I'm hoping this doesn't lead to other problems.

thanks
Phallanx replied on at Permalink Reply
Phallanx
@lackadaize
The "warning" is saying that Miser cannot delete the CDNS cache file due to permissions in the Miser_Support directory. Either allow permission to delete the file or disable CDN Usage.

Why are you renaming site.php?
As stated before. You need to remove/rename view.php in the [root]/libraries directory to remove Miser if you don't have the addon. Then you can delete other Miser files if you so wish.
lackadaize replied on at Permalink Reply
lackadaize
I meant view.php. Sorry it's been a long night of troubleshooting. I tried renaming it to -view.php, deleting only view.php, and deleting it along with the miser_support folder. I'll keep trying.

I had enabled all file permissions for the CDNS cache file (777) and I still got the error. so I just deleted it.
lackadaize replied on at Permalink Reply
lackadaize
or disabled it rather.
lackadaize replied on at Permalink Reply
lackadaize
In my server error log I keep getting something similar to the following:

[Wed Jul 17 09:25:13 2013] [error] [client 71.244.102.231] PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required '/home/eclinicalsol/www/eclinicalsol.exstream.tv/libraries/view.php' (include_path='/home/eclinicalsol/www/eclinicalsol.exstream.tv/libraries/3rdparty:/home/eclinicalsol/www/eclinicalsol.exstream.tv/concrete/libraries/3rdparty:.:') in /home/eclinicalsol/www/eclinicalsol.exstream.tv/concrete/core/libraries/loader.php on line 30

[Wed Jul 17 09:25:18 2013] [error] [client 71.244.102.231] PHP Warning: require_once(/home/eclinicalsol/www/eclinicalsol.exstream.tv/libraries/view.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in /home/eclinicalsol/www/eclinicalsol.exstream.tv/concrete/core/libraries/loader.php on line 30
Phallanx replied on at Permalink Reply
Phallanx
@lackadaize
If you have problems after removing Miser and the view.php, it is more than likely that you have cache enabled (Concrete5 caches overrides, I believe). This is the reason that it is suggested that you only remove the view.php because if this is the case, the site won't break, but you will find Miser is still enabled even though you have removed it. On clearing the cache you will then find that Miser is indeed disabled.

Changing the permission of the file itself is not enough. Once it is deleted and recreated again, you will be back to the permission warning as the default permission will once again be applied. You need to change the permission of the entire directory so that when it is recreated, it will adopt the directories permissions.

Hacking and overriding the deletion will cause issues in that you will not be able to change any of the CDNS and you may find you get the wrong jquery replacements.
lackadaize replied on at Permalink Reply
lackadaize
thanks that was all very helpful.
Remo replied on at Permalink Reply
Remo
For 5.6.2 you'll probably have to make "setThemeForView" "protected" instead of "private".

@Phallanx Have you ever thought about moving your code to github? That would make it much easier for us to help you improve miser!
Remo replied on at Permalink Reply
Remo
I found an issue:

On windows __FILE__ to get the path to the compliance files fails, it will include c:\...

I'll try to be a bit more precise, but I'd also send you some pull requests for that - but we need git for that ;-)
Phallanx replied on at Permalink Reply
Phallanx
@Remo.

Add at around line 854
$this->compliance["CONTENT"]=str_ireplace($_SERVER['DOCUMENT_ROOT'],"",$this->compliance['CONTENT']);
Remo replied on at Permalink Reply
Remo
That works, thanks!
Any reason not to update your repository?
Remo replied on at Permalink Reply
Remo
I couldn't find anything in this discussion nor in README file - where do I find sprite_gen.php ?
Phallanx replied on at Permalink Reply
Phallanx
@Remo

>Any reason not to update your repository?

Give me a chance. I only read your bug report 5 mins ago!(havn't even tried my fix yet ;) )

>I couldn't find anything in this discussion nor in README file - where do I find sprite_gen.php ?

There is no sprite_gen.php. Sprites aren't currently supported.
Remo replied on at Permalink Reply
Remo
Ups, sorry! I thought you already know about it since you were so quick ;-)
Phallanx replied on at Permalink Reply
Phallanx
@Remo.

Lol. Nope. I'm just very eu fait with the code and know how to fix stuff from the code smell.
ecomatt replied on at Permalink Reply
ecomatt
i have been getting this error on my new site: any idea why?
Warning: file_get_contents(.../public_html/newsite/helpers/miser_support/CDNS_cache.txt) [function.file-get-contents]: failed to open stream: Stale NFS file handle in .../public_html/newsite/helpers/miser_support/miser_CDNS.php on line 28

Warning: Invalid argument supplied for foreach() in .../public_html/newsite/helpers/miser_support/miser_CDNS.php on line 114

I have re created the CDNS_cache.txt file blank with chmod 777 and i haven't seen the error for a while but it never occurred every time in the first place?

what is the CDNS_cache.txt file do i need it and should it have text inside it?

thanks
Phallanx replied on at Permalink Reply
Phallanx
@ecomatt

Not sure. The warning is indicating that there is a stale file handle.

http://docstore.mik.ua/orelly/networking_2ndEd/nfs/ch18_08.htm...

The CDNS_cache.txt is a cache of, well, the CDNS. When Miser first starts, it generates this file if it does not exist and it will be changed when modifications are made in the CDNS tab of the addon. It is only used if the CDN replacement feature is active (which it is by default).
ecomatt replied on at Permalink Reply
ecomatt
thanks for your replay could it have anything todo with the fact that i deleted the "compliance" folder as i didnt want the cookies thing to pop up.
Phallanx replied on at Permalink Reply
Phallanx
@ecomatt

I couldn't say. Many funny things can happen if you go randomly deleting things.

It tells you in the readme how to turn off the EU Cookie compliance.
ecomatt replied on at Permalink Reply
ecomatt
OK understood. So i have put everything back and have disabled cookies as suggested in the site.php. but still i get intermittent errors.
this time when i was adding a new stack.

Warning: file_get_contents(mhworkshop.co.uk/public_html/newsite/helpers/miser_support/CDNS_cache.txt) [function.file-get-contents]: failed to open stream: Stale NFS file handle in/mhworkshop.co.uk/public_html/newsite/helpers/miser_support/miser_CDNS.php on line 28

Warning: Invalid argument supplied for foreach() in /mhworkshop.co.uk/public_html/newsite/helpers/miser_support/miser_CDNS.php on line 114

the site is locatedwww.www.mhworkshop.co.uk/newsite...
any thoughts on how i can stop this from happening please.
Thanks
ecomatt replied on at Permalink Reply
ecomatt
iv had to disable the miser as i was getting these errors more often now. and i needed to put the site live.
im running 5.6.1.2 so not sure if that has something to do with it?


Warning: file_get_contents(/var/sites/m/mhworkshop.com/public_html/newsite/helpers/miser_support/CDNS_cache.txt) [function.file-get-contents]: failed to open stream: Stale NFS file handle in/var/sites/m/mhworkshop.com/public_html/newsite/helpers/miser_support/miser_CDNS.php on line 28

Warning: Invalid argument supplied for foreach() in /var/sites/m/mhworkshop.com/public_html/newsite/helpers/miser_support/miser_CDNS.php on line 114

Warning: Invalid argument supplied for foreach() in /var/sites/m/mhworkshop.com/public_html/newsite/helpers/miser_support/miser_CDNS.php on line 114

Warning: Invalid argument supplied for foreach() in /var/sites/m/mhworkshop.com/public_html/newsite/helpers/miser_support/miser_CDNS.php on line 114

Warning: Invalid argument supplied for foreach() in /var/sites/m/mhworkshop.com/public_html/newsite/helpers/miser_support/miser_CDNS.php on line 144

Warning: Invalid argument supplied for foreach() in /var/sites/m/mhworkshop.com/public_html/newsite/helpers/miser_support/miser_CDNS.php on line 144

Warning: Invalid argument supplied for foreach() in /var/sites/m/mhworkshop.com/public_html/newsite/helpers/miser_support/miser_CDNS.php on line 144

Warning: Invalid argument supplied for foreach() in /var/sites/m/mhworkshop.com/public_html/newsite/helpers/miser_support/miser_CDNS.php on line 144

Warning: Invalid argument supplied for foreach() in /var/sites/m/mhworkshop.com/public_html/newsite/helpers/miser_support/miser_CDNS.php on line 144
Phallanx replied on at Permalink Reply
Phallanx
@ecomatt
Well. I can stop it from happening with the Miser CDN file. However, I think you will find it just moves to another file somewhere.

On line 16 of miser_CDNS.php in the miser_support directory
Change from
public $use_cache=TRUE;


to

public $use_cache=FALSE;


Then delete the CDNS_cache.txt file. It will not be regenerated and the warning should disappear.
prpdesigns replied on at Permalink Reply
prpdesigns
My metatags in the head section aren't finished with a trailing slash... how to change that?
Phallanx replied on at Permalink Reply
Phallanx
@prpdesigns
Are you sure Miser is doing that? The only think I can think of that *might* affect meta tags is the HTML compression. Try turning that off with
define (MISER_MINIFY_HTML,0);
Remo replied on at Permalink Reply
Remo
I found another problem that causes Miser to minimize the JavaScripts with every request. Took me a few minutes to track that down.

If I let miser minimize the inline JavaScripts (default behaviour), it will recreate the file all the time as it gets a different hash with every call.

The reason for this is rather simple: There's a JS variable called CCM_SECURITY_TOKEN which changes with every page request.

I think you might want to consider to disable inline script minimization by default or add some kind of filter to keep certain inline styles inline..?
Phallanx replied on at Permalink Reply
Phallanx
@Remo
Miser already has this capability.

It states in the readme

"If you have any
javascript that generates different code on each view; it is recommended
to add it to the "keys_no_file" list or to place your code in-line and
prevent MISER from puting in-line code into a file using the
"inline_js_to_file(FALSE)" option."

If you look in the miser_bridge_C5.php you will see that it has a line

$this->keys_top_footer   ( array ('var CCM_TOOLS_PATH') );


This means that the whole section that has the tools path (which has historically also had the security key) is placed in-line at the bottom. I'm not sure why your specific install has it in a different location to all the others so it is not included.
Remo replied on at Permalink Reply
Remo
I'm aware about the hint in the README, I just suggested to change the default behaviour but I haven't seen that bridge file.

I'll track down the problem there. I'm sure I'll figure out why the token was minimized.
Remo replied on at Permalink Reply
Remo
it's not part of the same script tag, these are the codes I can find in the core:

<script type="text/javascript">
<?php 
$valt = Loader::helper('validation/token');
print "var CCM_SECURITY_TOKEN = '" . $valt->generate() . "';";
?>
</script>


$disp = '<script type="text/javascript">'."\n";
$disp .=  "var CCM_SECURITY_TOKEN = '" . $valt->generate() . "';"."\n";
$disp .= "</script>"."\n";


I updated the bridge code to look like this:

$this->keys_top_footer   ( array ('var CCM_TOOLS_PATH','var CCM_SECURITY_TOKEN') );


works fine now!
Phallanx replied on at Permalink Reply
Phallanx
@Remo
I'll add it to the next update. What version of concrete5 are you looking at?
Remo replied on at Permalink Reply
Remo
Phallanx replied on at Permalink Reply
Phallanx
@Remo.

Good catches and great feedback. I'll update the repository at the weekend.
Remo replied on at Permalink Reply
Remo
@Phallanx: I saw some comments about creating a miser package but I have to admit that I haven't read every comment.

I just noticed that the code on sf.net involves some core overrides which imho aren't necessary. I just added a controller.php and put everything in a package:

http://github.com/Remo/miser

Any reason not to do that?
Phallanx replied on at Permalink Reply
Phallanx
@Remo

There is a package addon which enables complete configuration of Miser from the admin panel. It is the value added component of the commercial waiver and therefore only available to paid customers.

I would suggest you read the licencing very carefully before cloning Miser to another repository.
Phallanx replied on at Permalink Reply
Phallanx
Miser 1.8.3 has just been released as of 29/08/2013

The is a compatibility update which adds the view.php for concrete 5.6.2.

Also resolves the issue reported by Remo
furehead replied on at Permalink Reply
furehead
Thanks for this great tool! It really works :-)

I first had problems with the minify function for javascript which resulted in an js-error (only in current Firefox in combination with jquery ui 1.10.1).
I could solve this by downloading the current minify version and overwriting jsmin.php with that one from the current minify version 2.1.7.

Maybe in one of the future releases you might want to integrate this into the miser sourceforge files.
Phallanx replied on at Permalink Reply
Phallanx
@furehead
Your a bit late for this release (ony a few hours ago)

I'll look into it for the next one. Where did you download it from?
laaaamb replied on at Permalink Reply
laaaamb
After installing Miser I have only one issue. A form (iframe) that is present in my sites footer, wrapped in a div gets moved to the bottom of the document when miser is installed, thus pulling it out of its rightful inline place in the footer and placing it at the bottom of the page.

Is there a way to change this?

thanks
Phallanx replied on at Permalink Reply
Phallanx
@laaaamb.

Yes. You need to get Miser to ignore it by adding a unique keyword to the ignore list.

So find something that identifies the piece of code uniquely (eg a file name like my_non_relocatable_code.js) and add the following to your site.php
define('MISER_KEYS_IGNORE','my_non_relocatable_code.js');


(of course replacing my_*non_relocatable_code.js* with whatever keyword is appropriate-doesn't have to be a file name, BTW)
laaaamb replied on at Permalink Reply
laaaamb
Works a treat. Thanks for your help.

Guess I skim read a little too much of this huge thread to notice you giving the same advice countless times before ;)
mbaxter91288 replied on at Permalink Reply
mbaxter91288
@Phallanx

Hi Phallanx,

I am trying to use the EU Cookie Compliance but I do not get the HTML appear at the top of my browser. I have tried the following:

- added define('MISER_EU_COOKIE', "my_cookie_name"); to the site.php
- cleared cache
- checked all cache settings are turned off
- cleared all cookies
- tried disabling Miser - clearing cache - re-enabling miser

Also when I add the below code and get this error?

define( 'MISER_COOKIES',"my_cookie" );

Error:
Fatal error: Call to undefined method MiserHelper::del_cookies() in /FILEPATH_TO_PROJECT/helpers/miser.php on line 81

Any help would be greatly appreciated.
Cheers,
Mat
Phallanx replied on at Permalink Reply
Phallanx
@mbaxter91288

Interesting.

Take a look in miser.php at the line stated in the error (81?) and change "$this->del_cookies" to "$this->cookies"
mbaxter91288 replied on at Permalink Reply
mbaxter91288
@Phallanx

Hey,

Thanks for the quick response! I've changed line 81 to:

if (defined( 'MISER_COOKIES' ) ) $this->cookies (array_map('trim',explode(',',MISER_COOKIES)), $this->replace_keys );

This doesn't bring the error anymore but doesn't matter what cookies I define in my site.php it will still set them (and still no message to accept cookies) :-/

Cheers,
Mat
Phallanx replied on at Permalink Reply
Phallanx
@mbaxter91288
Do you have a link to the site?
mbaxter91288 replied on at Permalink Reply
mbaxter91288
@Phallanx

Just working on the site locally at the moment so unfortunately not :(

Cheers,
Mat
Phallanx replied on at Permalink Reply
Phallanx
@mbaxter91288

Do you have any javascript errors?
Phallanx replied on at Permalink Reply
Phallanx
@mbaxter91288

Just to close this for the benefit of others.

The issue with the Cookie banner not showing was traced offline via PM. It was found that the HTML body tag used an ID <body id="main">)which Miser wasn't expecting and therefore couldn't inject the banner code.

The new regex to cope with this will be in he next release.
snobo replied on at Permalink Reply
snobo
Hi Phallanx,

I'm afraid I have to ask your help, as all my attempts to use MISER's defines to retain the right order of CSS links in the sorted html failed. So, this is the simplified fragment of the HEAD with MISER disabled:

<link href="/concrete/css/ccm.base.css" />
<link href="/packages/someplugin/css/plugin.css" />
<link href="/themes/mysite/css/normalize.css" >
<link href="/themes/mysite/css/typography.css" />
<!--[if gt IE 8 | !IE]><!-->
<link href="/themes/mysite/css/mysite.css" >
<!--<![endif]-->
<!--[if (lt IE 9) & (!IEMobile)]>
<link rel="stylesheet" href="/themes/mysite/css/mysite-ie.css" type="text/css">
<![endif]-->


As you see, I'm using conditional comments to feed different style sheets to older IE and to good browsers (if you wonder why, these style sheets are generated from the same SASS fragments, but mysite-ie.css doesn't use media queries).

So, when I enabled MISER I understood that I have to define('MISER_KEYS_IGNORE', 'mysite.css'), otherwise it is taken out of the conditional comments and combined with other CSS, which is not what I want. BUT in that case the order is messed up:

<!--[if gt IE 8 | !IE]><!-->
<link href="/themes/mysite/css/mysite.css">
<!--<![endif]-->
<link href="/files/cache/css/09c1d98dd9d4231c8a3c80a1b33ba0cf_merge.css" />
<!--[if (lt IE 9) & (!IEMobile)]>
<link href="/themes/mysite/css/mysite-ie.css">
<![endif]-->


You see, MISER puts the ignored CSS first, before all the combined CSS. And this is exactly the problem, because in mysite.css I override quite a few styles from ccm.base.css or various plugins; so naturally mysite.css must go AFTER. So, is there any way to control the order of ignored and combined CSS?
Phallanx replied on at Permalink Reply
Phallanx
@snobo
Always ask if your not sure. I'm always looking for improvements and if you identify a common use case that Miser cannot cope with, then I'll see what I can do.

Miser ignores selects, then combines everything else and places the combined file before them. It assumes that selects are overrides to previous definitions and most designers use them that way (as I believe you are)

So in your example, you just use Misers default settings and everything should be fine, unless I've missed something.

Aha.
I did miss something.

You are not defining the link type e.g.

<link rel="stylesheet" type="text/css"
snobo replied on at Permalink Reply
snobo
@Phallanx,

as I said, I simplified my code examples to make them more readable here - but maybe it's indeed not really obvious and confusing. So in reality of course rel="stylesheet" type="text/css" are present...

What do you mean by "selects" that Miser ignores? And as I also said, I tried using it "as is" without specifying MISER_KEYS_IGNORE and the result was even worse, because Miser took mysite.css out of the conditional comment.
jasteele12 replied on at Permalink Reply
jasteele12
Maybe because the markup is wrong?

It should look like this:

<!--[if gt IE 8 | !IE]>
<link href="/themes/mysite/css/mysite.css" >
<![endif]-->


Instead of this:

<!--[if gt IE 8 | !IE]><!-->
<link href="/themes/mysite/css/mysite.css" >
<!--<![endif]-->
Phallanx replied on at Permalink Reply
Phallanx
@jasteele123

Yup. That would do it too
snobo replied on at Permalink Reply
snobo
@jasteele123, you didn't get the point of the trick used in this comment :) This one must be visible to all browsers (while ignored by IE less than 9)! Hence internal closing and reopening comments. If I did as you suggested none of browsers except IE would use this CSS file.

And finally, I don't think it even matters. Miser is not confused by conditional comments, it simply orders the CSS files in its own way...
Phallanx replied on at Permalink Reply
Phallanx
@snobo

I mean the Internet Explorer conditional statements.

Ignoring Conditional Statements isn't going to work. Because, although they are ignored, everything gets moved and reorganised around them.

However. Try this:

Find on about line 389 of Miser .php
if ( preg_match_all( '#<\s*!\s*--\s*\[\s*if.+-->#smUi',$html,$selects )>0 ) {


And replace with
if ( preg_match_all( '#<\s*!\s*--\s*\[\s*if.+\]-->#smUi',$html,$selects )>0 ) {


That will tighten up the regex for finding Conditional statements. Now.
I had a lot of problems with Conditional statements in the early days (just so many ways people abuse them). So I won't say this will go in the next release (which will go out this weekend) until I've thoroughly thought it through and tested it on some major sites. I don't want to break sites that are already out there that may be relying on this [miss]behaviour.
snobo replied on at Permalink Reply
snobo
Dear @Phallanx,

thanks so much for this super quick fix! I wish every software had such an amazing support :) So, this works for me.

However, at the same time I finally discovered the reason for a JS bug that starts to appear whenever MISER processes certain JS libraries. For example, minified JS script that comes with Touch Gallery
http://www.concrete5.org/marketplace/addons/touch-gallery/... has the following line:

while(n.innerHTML="<!--[if gt IE "+ ++t+"]><i></i><![endif]-->",r[0]);


And after being concatenated by MISER along with other JS files, it becomes:

while(n.innerHTML="<!--[if gt IE "+++t+"]><i></i><![endif]-->",r[0]);


Note the disappearing space character. This results in JS bug and the script no longer works. Similar (or even the same) code chunk is included in Jquery Mobile, so this library gets corrupted as well.
Phallanx replied on at Permalink Reply
Phallanx
@snobo

Interesting.

Miser uses jsmin for minification. So I suspect that it's not the only one to break that code. If you can give me a keyword, I will add it to the "unfriendly" list so that others can benefit from your tenacity in finding the issue.

Nice find!

Phallanx.
snobo replied on at Permalink Reply
snobo
@Phallanx,

please explain, what keyword are you asking for?

and JSmin, quite an old project, no? I've had some issues with it myself, maybe any of the more up-to-date compilers should be considered as an alternative?
Phallanx replied on at Permalink Reply
Phallanx
@snobo

Miser has lists that enable us to dictate its behaviour (the most used is probably the "Ignore" list). Each list (there are 6 of them) are lists of unique strings that target a specific piece of code. For example, you can add "myjavascript.js" to the ignore list and any script tag that has that string somewhere in it, will be ignored. By adding such a keyword we can opt-out that piece of code from the optimisation process or move it around the page.

Miser already knows about google adverts, doubleclick.net etc as generic things not to fully optimise. It also knows about some CMS specific modules/addons such as tony_tracker and recaptcha. I'm just suggesting that if you know a unique string that can target this addon, I can add it also.


The JSMin is circa 2012. So not really that old. But there are, actually, very few pure PHP minifiers. This is the first report of a minifying problem and Miser can cope with it, sort-of, by either leaving it out of the optimisation process or turning off minification. Whilst Miser tries hard for 100% optimisation there will always be some that resist, hence the lists and the other options.
snobo replied on at Permalink Reply
snobo
@Phallanx,

As far as I understood this chunk of code is not associated only with a specific plugin or library, because it comes from a very neat script that detects older IE the most reliable way:

http://james.padolsey.com/javascript/detect-ie-in-js-using-conditio...

so I see that many libraries and plugins use this approach with different modifications. I guess the only reliable string that can be used as a "keyword" is based around the conditional comment itself. The two examples I have at hand:

innerHTML="<!--[if gt IE "+ ++a+"]><br><![endif]-->"


innerHTML="<!--[if gt IE "+ ++t+"]><i></i><![endif]-->"


If regexp are supported in your opt-put filter, the keyword should be adjusted to take into account all possible variations of the self-incremented variable name, the contents of the CC, and spacing/quotes.

Or, if we can afford KISS, maybe just
innerHTML="<!--[if gt IE "


would do (still with regexp-ed adjustment to allow spacing/quotes variations)?

However, if you follow this way, the presence of this construct would effectively exclude any library/plugin from MISERification process. Wait... Btw: according to your readme.txt, Javascript minification control is set to INLINE ONLY! I haven't changed this setting. So how come this script is getting rewritten in the first place? IMU only concatenation should have been performed! So maybe the problem is not in JSmin?
Phallanx replied on at Permalink Reply
Phallanx
@snobo

No. That is just an example. All features are on by default.

Well. If it's not a specific addon. Then maybe target the problem directly. I could add "+ ++" then that should catch them all.

Made me laugh looking at the Github for JSMin where his last entry was

"Stop using this thing, dammit."

So perhaps an alternative might be wise.
Phallanx replied on at Permalink Reply
Phallanx
@snobo
That site that you linked to.
The snippit doesn't suffer from the issue.
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->'
snobo replied on at Permalink Reply
snobo
@Phallanx

because it's the *original*, unminified version. In my examples earlier I've been talking about already minified scripts - try this one for example
http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js...

both plugins that suffer from the problem in my case provide already minified code - I've included extracts from that in my previous post
Phallanx replied on at Permalink Reply
Phallanx
@snobo

In fact. It is warned by the original author that this is an issue
http://www.crockford.com/javascript/jsmin.html...

Thinking on-the-fly here. It could be a cheap way of detecting already minified code (not all code, but some) so that re-minifaction doesn't happen at all.
snobo replied on at Permalink Reply
snobo
@Phallanx

indeed! Exactly the same scenario ;)

Btw, I tried to disable minification via MISER_MINIFY_JS define, but apparently the JS cache must be cleared in order for changes to get into effect. Here I come to a question that I also wanted to ask before:

is it still true that the only way to clear the cache is manually deleting all files in /files/cache/js OR purchasing the commercially-available addon? I cannot delete those files via FTP as I don't have write permissions for this folder.

Secondly, when trying to see if I can just run $m->cache_clear (before finding out from this thread that I can't), I saw that according to readme.txt, $m->cache_clear( FALSE ) is suppposed to accept boolean parameter. However, in the miser.php you have:

Private function clear_cache($what=1){
  $ret=FALSE;
  if ($what && 1){
    $ret =  ($this->del_dir( $_SERVER['DOCUMENT_ROOT'] . $this->dir_css,'_merge.css') && 
         $this->del_dir( $_SERVER['DOCUMENT_ROOT'] . $this->dir_js, '_merge.js'));
  }
  if ($what && 2){
    $ret =$ret || $this->CDNS->Clear_Cache();
  } 
  return $ret;        
}


$what && 1 and $what && 2, hmm? Looks like an invalid (or obsolete) attempt to support a bitmask check, no?
Phallanx replied on at Permalink Reply
Phallanx
@snobo
This thread is 2 years old now. So some information maybe/is probably outdated.

The cache_clear command was introduced specifically for the addon along with the cache size functions. Originally, the only way was via FTP. The addon came a long time after the Miser code itself as I needed a better/easier way to troubleshoot and no-one else took up the challenge (the addon makes life so much easier, especially when things aren't 100%) So I don't see any reason why you can't call that function from your own script as the addon does.

Looks to me like a transitional bug (the double ampersands). The function used to just be boolean, but I wanted more control.

Really the CDN cache should go in one of the other directories just in case the miser_support directory doesn't have the permissions. The option would then be obsolete.
mnakalay replied on at Permalink Reply
mnakalay
@snobo
Following your message I made a modification to Touch Gallery to play nice with Miser.
It's now version 1.4.4 if you want to update
snobo replied on at Permalink Reply
snobo
@mnakalay
Excellent! Thanks a ton, works like a charm!
Phallanx replied on at Permalink Reply
Phallanx
Miser 1.9.0 has just been released as of 09/11/2013.

It addresses the following issues:

1. Body tags containing markup are now supported
2. Clear cache using incorrect comparison operators corrected.
3. Clear cache now supports access time checking.
4. CSS url paths containing embedded images are now supported.
5. Check for "+ ++" in minification
6. Added a Cache clearing "Job" for the addon
7. Modified I.E. conditional statement regex to be more strict
8. Added "goodle-analytics" to the default GA detection.
9. Added "ccm_token" to default footer JS detection (friendlier to addons utilising ajax calls)

Thank you all for your patience and feedback to improve Miser.
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
Hi @Phallanx
One small issue, when I run my site through the WebPageTest site I see a 403 forbidden error on the root/files/ folder?
The site is otherwise working okay with no obvious side effects,
Any idea what could be causing this..
I have checked the file permissions for the root/files/ folder and it is set at 755..
Phallanx replied on at Permalink Reply
Phallanx
@weyboat
Miser doesn't put anything in the [root]/files folder (or at least shouldn't). Do you have a link?
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
Phallanx replied on at Permalink Reply
Phallanx
@weyboat
It's you shortcut icons. There are no filenames.
Can you turn miser off so I can see what they are really?
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
Okay thats done
Phallanx replied on at Permalink Reply
Phallanx
@weyboat
Well. They still don't have filenames. So it isn't Miser.
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
You are correct,
I have this my header_required file
<?php  echo $f->getRelativePath()?>

on lines 90 and 91 so I will track it down from there..

Thanks for the heads up..
snobo replied on at Permalink Reply
snobo
@Phallanx,

it seems that in the new version JS minification no longer works (disregarding the value or presence of MISER_MINIFY_JS constant).

Furthermore, my troubles with the order of scripts continue...

I am using the Placehodler polyfill, feeding it only for IE:

<!--[if IE]>
<script src="jquery.placeholder.min.js"></script>
<![endif]-->


Naturally, jQuery.js itself should be already attached somewhere above the placeholder plugin, and that's how it is in the original code. However, after MISERification jquery.js always goes below, no matter what I do. E.g. I added this definition:

define('MISER_KEYS_HEAD', 'jquery.js');


but jquery.js still went right below the placeholder in the HEAD. Then I moved placeholder to the footer; but MISER puts it in the HEAD! And MISER_KEYS_FOOT doesn't help. Again, I'm stuck...
Phallanx replied on at Permalink Reply
Phallanx
@snobo
[quote]
it seems that in the new version JS minification no longer works (disregarding the value or presence of MISER_MINIFY_JS constant).
[/quote]

Do you have a script with "+ ++"?

[quote]
I am using the Placehodler polyfill, feeding it only for IE:

<!--[if IE]>
<script src="jquery.placeholder.min.js"></script>
<![endif]-->
<snip>
define('MISER_KEYS_HEAD', 'jquery.js');
<snip>
HEAD! And MISER_KEYS_FOOT doesn't help. Again, I'm stuck...
[/quote]

Here you really are are stuck.

Miser assumes IE statements are for overriding CSS only and always places the statements after CSS links but before Javascript ones (when using the MISER_KEYS_HEAD). CSS links/inline, Javascript links/inline and IE statements are all treated as blocks, so there is no resolution between them which is what is required for this scenario. For javascript, you will need to use a different method of browser detection.

An additional point as regards IE statements. They are not optimised. They are basically added to the "ignore list" and don't get combined or minified. The rational here is that rather than generate 100s of MBs of cache files (one for each browser, for each page) all with one or two lines difference just on the off-chance someone is using, say, IE 6. The majority of the time they are not used at all and therefore do not impact performance.

I will put a note in the readme file to outline these limitations.
snobo replied on at Permalink Reply
snobo
@Phallanx

yes, I have a script with "+ ++" (which is already minified statically) but the point is that all the *other* scripts are not minified by Miser. In other words, if Miser finds just one file with "+ ++", it no longer minifies any other scripts that are concatenated along with it. Which doesn't seem right to me.
Phallanx replied on at Permalink Reply
Phallanx
@snobo

The approach with Miser is that it should degrade gracefully so whilst not ideal, if it allows javascript to operate, then that is better than not. The easy (rather than the optimal) solution is to ignore the offending javascript rather than to completely rewrite Miser for an edge case.

However. This is a stop-gap solution. I have already found another minifier that doesn't suffer from the "+ ++" flaw and that will be included with the next release. Until then, you can add it to the ignore list and everything will then be minified.
snobo replied on at Permalink Reply
snobo
@Phallanx

ok, thanks for clarifications and fixes! As you advised, added that script to ignore list. And switched to more correct placeholder polyfill loading:

if (!('placeholder' in document.createElement('input'))) $.getScript('jquery.placeholder.min.js')
snobo replied on at Permalink Reply
snobo
@Phallanx

btw, am I right that these days MISER can work nicely with C5 cache switched on? By browsing this looooong thread I got an impression that back in the day there have been issues, and you used to advise disabling C5 cache, but then later on the issues have been fixed. Is it correct?
Phallanx replied on at Permalink Reply
Phallanx
@snobo
I still advise turning cache off.

The issue has always been that the cache bypasses Miser as it operates late in the page creation process, just before rendering. A site with Miser enabled without cache still performs much better than a site without Miser and cache in most scenarios (full page cache included) because page generation by the CMS is only a small portion of a sites responsiveness.

Remember. Miser doesn't make your *site* faster. It allows your *browser*" to start to render the page earlier so to the user it *seems* faster.
Phallanx replied on at Permalink Reply
Phallanx
Miser 1.9.1 has just been released as of 18/11/2013.

If contains an updated Javascript and HTML plugin that addresses already minified scripts that have "+ ++".
alphaplus replied on at Permalink Reply
alphaplus
Hi there!

I'm trying optimiser and for so far it works great, kudos!
Only yesterday i've got a mail from my hosting that the folder /files/cache was more than 4.5gb.

So i've looked in the folder /files/cache and saw that /files/cache/css and /files/cache/js were extremly big.
Am i doing something wrong?

Much appreciated.

Regards
Phallanx replied on at Permalink Reply
Phallanx
@alphaplus

Exactly how big are the CSS and JS directories?

It is possible for the JS directory to grow if there is some javascript that changes on every view (CSS should be static unless editing). An example might be that a piece of Javascript produces a random hash on each page view. In this scenario, the Javascript should be added to the ignore list. If you are editing CSS, then the CSS directory will also grow since you are changing the CSS every time.

You can delete the CSS and javascript directories and Miser will regenerate what it needs. So if you delete the CSS and JS directories, then visit each page in your site once, you will see how much Miser needs.
Remo replied on at Permalink Reply
Remo
There seems to be a problem with webfonts included in the CSS.

Here's an example:

@import url("http://fast.fonts.net/cssapi/eb11a63a-274c-4773-be9c-1227f2b3acc6.css");
body {
    font-family: 'Myriad W01 Lt', sans-serif;
    font-size: 17px;
    line-height: 22px;
}


the import is gone after the file is merged. Any idea on how to fix this?
Phallanx replied on at Permalink Reply
Phallanx
@Remo
A remote @import? I've never seen anyone do that...lol.

Easiest solution is to turn off @import merging.

Another is to load the CSS used in the @import from the local server rather than remotely, or use a CSS link to them instead of @import. This is probably the most desirable as @imports block page rendering on some browsers.

The third option is to ignore the CSS that contains the remote @import if other CSS files are using them for local content.

I'll put a check for remote @imports (to ignore them properly) in the next release.
Remo replied on at Permalink Reply
Remo
Remote @import's seem to be the easiest way to include webfonts in typography.css. Something we do to make sure the fonts in the content block look the same.. It's the only reason why we're doing it.

I'll make some tests to see if it works without merging import's.. Thanks!
Phallanx replied on at Permalink Reply
Phallanx
@Remo.
Sure, they are easy. But they and webfonts (webfonts also sequentially block downloading) are an anathema to performance which is why Miser unrolls @import by default. Add in a remote location and you are really getting a perfect storm with the addition of http requests, especially if the remote CSS also uses @import for more CSS.

So the slowest way you can serve CSS is via @import remotely and throw in webfonts. The browser can't start to render the page until all the CSS has been resolved and a lot of it is sequential rather than parallel.

http://www.stevesouders.com/blog/2009/04/09/dont-use-import/...
Remo replied on at Permalink Reply
Remo
Well, yes.. But have you ever tried to tell a graphic designer not to use web fonts? And if they do, you have to include them in typography.css which is why it's (almost) the only way.

I can only imagine one way to improve it.

Let miser read the remote file, make relative URLs absolute and then merge the whole thing into the main css files. TinyMCE would still use the @import to load the font, but performance when editing a page isn't that much of a problem to me, and normal website visitors would have a better performance.
Phallanx replied on at Permalink Reply
Phallanx
@Remo.
Nope. Miser will never look for files offsite.

The performance would be diabolical and worse than doing nothing (it was tested in the early days). The CURL minimum timeout is 1 second (a local file, on the other hand is usecs)and PHP scripts are sequential. It will kill a website which kind of defeats the point. Remember that Miser works "on-the-fly" and checks all files every time it is invoked.

So the best way for Miser to deal with a HTTP URL is to quietly ignore it (which is what happens with all CSS and javascript URLS that cannot be found locally or are offsite-not just @import). If it is an issue, the developer can download the file to a local location and Miser will then deal with it as normal - it only has to be done once.

PS.
If graphics designers cared about performance as much as eye candy, Miser wouldn't be needed :P
Remo replied on at Permalink Reply
Remo
I understand that you don't want to add dependencies to remote files. I don't think it's a big deal performance wise as you cache the output, but when remote files aren't available, it could mess up the whole thing.

Ignoring is certainly fine with me!
Phallanx replied on at Permalink Reply
Phallanx
@Remo.
Yes. But.......

When Miser is invoked, it loads all the files, MD5s the result and if the MD5 filename doesn't exist, then creates a cache file. However, the loading and MD5 happens regardless if there is an existing cache file or not. That's how Miser knows it needs to create one. The cache is for the browser, not Miser which always accesses the original files on each call. Using CURL you would have HTTP requests, sequentially, called many times just so Miser knows whether to create the cache file or not.

This is why I emphasised that Miser works "on-the-fly"
Phallanx replied on at Permalink Reply
Phallanx
Miser 1.9.2 has been released as of 17/3/2014.

This release supplies the view.php for Concrete5 version 5.6.3.

It also has the check for @import remote URLS reported by Remo.

This update is optional.
Remo replied on at Permalink Reply
Remo
Thanks Shaun, I'll test this!
Remo replied on at Permalink Reply
Remo
Still no luck, got another problem with imports. On that server, we're using newrelic which is now causing some issues. Here's the output:

Fatal error: Aborting! The New Relic imposed maximum PHP function nesting level of '5000' has been reached. This limit is to prevent the PHP execution from catastrophically running out of C-stack frames. If you think this limit is too small, adjust the value of the setting newrelic.special.max_nesting_level in the newrelic.ini file, and restart php. Please file a ticket at https://support.newrelic.com if you need further assistance. in /home/usr/customer/env-test/packages/miser/helpers/miser.php on line 662


This is one part of the code you have in your site with new relic

<script type="text/javascript">window.NREUM||(NREUM={}),__nr_require=function a(b,c,d){function e(f){if(!c[f]){var g=c[f]={exports:{}};b[f][0].call(g.exports,function(a){var c=b[f][1][a];return e(c?c:a)},g,g.exports,a,b,c,d)}return c[f].exports}for(var f=0;f<d.length;f++)e(d[f]);return e}({"4O2Y62":[function(a,b){function c(a,b){var c=d[a];return c?c.apply(this,b):(e[a]||(e[a]=[]),void e[a].push(b))}var d={},e={};b.exports=c,c.queues=e,c.handlers=d},{}],handle:[function(a,b){b.exports=a("4O2Y62")},{}],YLUGVp:[function(a,b){function c(){var a=m.info=NREUM.info;if(a&&a.agent&&a.licenseKey&&a.applicationID){m.proto="https"===l.split(":")[0]||a.sslForHttp?"https://":"http://",g("mark",["onload",f()]);var b=i.createElement("script");b.src=m.proto+a.agent,i.body.appendChild(b)}}function d(){"complete"===i.readyState&&e()}function e(){g("mark",["domContent",f()])}function f(){return(new Date).getTime()}var g=a("handle"),h=window,i=h.document,j="addEventListener",k="attachEvent",l=(""+location).split("?")[0],m=b.exports={offset:f(),origin:l};i[j]?(i[j]("DOMContentLoaded",e,!1),h[j]("load",c,!1)):(i[k]("onreadystatechange",d),h[k]("onload",c)),g("mark",["firstbyte",f()])},{handle:"4O2Y62"}],loader:[function(a,b){b.exports=a("YLUGVp")},{}]},{},["YLUGVp"]);</script>


and before the body is closed this:

<script type="text/javascript">window.NREUM||(NREUM={});NREUM.info={"beacon":"beacon-5.newrelic.com","licenseKey":"1111112","applicationID":"1111111","transactionName":"sRUMBaxFZVUNbWA9Osdf1Q==","queueTime":0,"applicationTime":445,"ttGuid":"","agentToken":"","userAttributes":"","errorBeacon":"jserror.newrelic.com","agent":"js-agent.newrelic.com\/nr-338.min.js"}</script>


I'll see if I can give you more information on this..
Remo replied on at Permalink Reply
Remo
I don't think it's because of new relic, that's just where the problems shows itself..

Maybe I'm missing something, but this looks like an infinite loop:

Protected function merge_imports($contents){
        static $count = 0;
        if ($count > 3) return ($contents);
        if (stripos($contents,'@import') === FALSE) return $contents;
        $num = preg_match_all( '#@import\s*(?:url\([\'"]?)?(.+?)[\'"\)]?;#i',$contents,$imports);                       
        if ( $num > 0 ){
                for ($i=0; $i < $num; $i++){
                        $url = $this->clean($imports[1][$i]);
                        if (stripos($url,"http") !== FALSE) continue;         // Ignore remote calls
                        $_contents = $this->get_files(array($url),"#(".$url.")#",TRUE);   
                        $contents = str_replace($imports[0][$i],$_contents,$contents);            
                }
                $contents = $this->merge_imports($contents);
        }
        $count++;


$contents isn't modified in my case since all imports start with http but it always finds two imports (fonts.com) and thus jumps into merge_imports again and again..
Phallanx replied on at Permalink Reply
Phallanx
@Remo

On inspection, it looks like the count++ should be before the next jump to $this->merge_imports($contents)

There is a check there for nested depth (3), but I can see that it can never be incremented.

I wonder why this hasn't shown up on the test servers. At least 2 of them have @import CSS.
Phallanx replied on at Permalink Reply
Phallanx
Yeah.

That's not gonna cut it.

The recursion relies on deleting the original entry so that it's not re-analysed on subsequent calls.

The cheap solution is to change it back to the original and call it a limitation ;)

To address this edge case will require a bit more thought. Good job I'm not into cheap solutions, eh? I'm thinking of a better regex for this instead.
Phallanx replied on at Permalink Reply
Phallanx
@Remo.

OK. I;ll be testing fully over the weekend, but in the meantime

Delete the line
if (stripos($url,"http") !== FALSE) continue;         // Ignore remote calls


and replace the line
$num = preg_match_all( '#@import\s*(?:url\([\'"]?)?(.+?)[\'"\)]?;#i',$contents,$imports);


With

$num  = preg_match_all( '#@import\s*(?:url\([\'"]?)(?:(?!http|www))(.+?)[\'"\)]?;#i',$contents,$imports);
franzz82 replied on at Permalink Reply
Hi Phallanx,

One question:

Is it possible disable Miser only in "Admin interface"?

Thanks
Phallanx replied on at Permalink Reply
Phallanx
@franzz82
Nope. You can disable Miser also by adding a define to your site.php.

define( 'MISER_ENABLE',FALSE );


or renaming/removing the view.php in the libraries directory.
garyjhills replied on at Permalink Reply
garyjhills
I was interested in using this on one of my sites to see if it worked so I downloaded the files but in the Concrete5 folder I can;t see one for the version I am running - 5.6.2.1.

I tried upgrading to the new 5.6.3 but it's not compatible with a few addons I have so will stay on my current version for a while at least.

Any advice if this will work with my version?

Gary
Phallanx replied on at Permalink Reply
Phallanx
@garyjhills
You should be fine with the view.php for 5.6.2.0
Erick replied on at Permalink Reply 1 Attachment
Erick
Hi,
and thanks in advance for your support :)

I have a problem with the path of the elements for the Cookies Banner.
How can I solve it? Thank you very much.
Phallanx replied on at Permalink Reply
Phallanx
Easiest and quickest solution is to modify the compliance.css and change (around line 59)

from
background-image: url('btn.png');

to

background-image: url('/concrete5/helpers/miser_support/compliance/btn.png');
Erick replied on at Permalink Reply 1 Attachment
Erick
Thanks for your answer,
but still I have a problem with file compliance.js that I can not recall. If I click on the button gives me an error as the screen.

Why these errors occurred?
Phallanx replied on at Permalink Reply
Phallanx
It's the way your server is expanding the paths.

You have "concrete5/concrete5" instead of just one concrete5.

Do you have a DIR_REL define in your site.php?
Erick replied on at Permalink Reply
Erick
Not, it has not DIR_REL.
In the file site.php is only present "define('MISER_EU_COOKIE','name_cookie');"
Phallanx replied on at Permalink Reply
Phallanx
OK.

Try adding

define('DIR_REL','/concrete5');

Is this on Windows or Linux?
Erick replied on at Permalink Reply 1 Attachment
Erick
Nothing, the error is still present.
The website is in Linux.

I think it is missing a slash at the time that the path is created.
Phallanx replied on at Permalink Reply
Phallanx
no. that was an old version that injected inline. My memory was failing me.
Erick replied on at Permalink Reply
Erick
I'm using Concrete 5.6.3.1 and Miser1.9.2.

Maybe there is an error in the view.php for 5.6.3.x or miser_bridge_C5.php? according to you?
Phallanx replied on at Permalink Reply
Phallanx
No. I was misremembering. sorry.

Line 907 is where is contructs the url.

$this->compliance["JS"]='<script type="text/javascript" src="'.$this->compliance['JS'].'"></script>';


and line 900 where it retrieves the script path

$this->compliance["JS"] = $this->clean(dirname(__FILE__)).'/miser_support/compliance/compliance.js';


So is "dirname(__FILE__)" not returning a leading slash?
Erick replied on at Permalink Reply
Erick
Exactly!

Miser 1.9.1b

// Load Compliance
         $this->compliance["JS"] = $this->clean(dirname(__FILE__)).'/miser_support/compliance/compliance.js';
         $this->compliance["CSS"] = $this->clean(dirname(__FILE__)).'/miser_support/compliance/compliance.css';
         $this->compliance["CONTENT"] = $this->clean(dirname(__FILE__)).'/miser_support/compliance/compliance.html';
         if (@file_exists($this->compliance["JS"]) && @file_exists($this->compliance["CSS"]) && @file_exists($this->compliance["CONTENT"]) ){
            $this->compliance["JS"]=str_ireplace($_SERVER['DOCUMENT_ROOT'],"",$this->compliance['JS']);
            $this->compliance["CSS"]=str_ireplace($_SERVER['DOCUMENT_ROOT'],"",$this->compliance['CSS']);
            $this->compliance["JS"]='<script type="text/javascript" src="'.$this->compliance['JS'].'"></script>';
            $this->compliance["CSS"]='<link rel="stylesheet" type="text/css" href="'.$this->compliance['CSS'].'" />';
            $this->compliance["CONTENT"]=@file_get_contents( $this->compliance["CONTENT"]);
            if ($this->compliance["CONTENT"] === FALSE){
               // Reported error on some windows platforms due to full path-remove ROOT
               $this->compliance["CONTENT"]=str_ireplace($_SERVER['DOCUMENT_ROOT'],"",$this->compliance['CONTENT']);
               $this->compliance["CONTENT"]=@file_get_contents( $this->compliance["CONTENT"]);
               if ($this->compliance["CONTENT"] === FALSE){
Phallanx replied on at Permalink Reply
Phallanx
So on the next line after "// Load Compliance"
Insert the line:
var_dump(dirname(__FILE__));


And refresh the page and look at the HTML source.

What does the path look like?
Erick replied on at Permalink Reply
Erick
Ok, done.

http://www.impesud.it/concrete5/...

I returns
string(49) "/web/htdocs/www.impesud.it/home/concrete5/helpers"
Phallanx replied on at Permalink Reply
Phallanx
OK.

You can delete that var_dump now and I suggest you delete that display of your path in the post too (to be safe).

I expect the next step would reveal that your Document root has a trailaing slash, which it should not.

I'll PM you the resolution.
Phallanx replied on at Permalink Reply
Phallanx
To bring this to closure.

The websites DOCUMENT_ROOT had an unexpected trailing forward slash.
Cleaning up the DOCUMENT_ROOT before loading support files made Miser more robust to this type of issue.

There will be defensive coding added in the next release to clean the DOCUMENT_ROOT before use.
DerCommodore replied on at Permalink Reply
OK my DOCUMENT_ROOT also has a trailing slash ... how to fix it?
DerCommodore replied on at Permalink Reply
Hey guys
I have a little problem with miser.
The urls of the compliance seem to not fit:
What I get is:
<link rel="stylesheet" type="text/css" href="projectA/helpers/miser_support/compliance/compliance.css"/>

instead of
<link rel="stylesheet" type="text/css" href="/projectA/helpers/miser_support/compliance/compliance.css"/>

As you can see the beginning / is missing.
I tried to fix it with
$this->set_root(DIR_BASE);

=> didn't work - path still wrong.

More important the CSS merge seems to be completely broken. Most of the files are not found and included.

Can some please help? What can be wrong ?- I would guess the subdirectory is making problems, but I can't figure it out.
I could manually add the slashes like in the solution above, but I think they are connected.
Phallanx replied on at Permalink Reply
Phallanx
Try this instead.

After line 66 where it says:
function __construct($root = NULL) {


Insert the following line after:

$this->set_root($_SERVER['DOCUMENT_ROOT'])


So it should now look like:
function __construct($root = NULL) {
         $this->set_root($_SERVER['DOCUMENT_ROOT']);
         $this->top_Foot_keys    = array();
DerCommodore replied on at Permalink Reply
Great! Thanks! - That fixed the path problem for compliance

The CSS combiner is still not working though for me. But I fear I have to look into it on my own, because it may be way to complicated with my CSS structure.

Thanks again!
Phallanx replied on at Permalink Reply
Phallanx
@DerCommodore

That will fix the trailing slash (maybe not the best place, but easy to explain).

To figure out CSS I would need to see the website but it shouldn't break your site by not combining.
Phallanx replied on at Permalink Reply
Phallanx
@mikejay

Setting the MISER_ENABLE define to FALSE only disables optimisation. It doesn't uninstall Miser so it will still try to load things like the CDN list. To uninstall Miser you need to rename or remove the view.php in the top level "libraries" directory if you are not using the addon module.

The error you describe is usually indicative of a corrupted CDN cache file. This file is found in the "miser support" directory and called "CDNS_cache.txt". Deleting the file and allowing Miser to recreate it usually resolves the issue.
mikejay replied on at Permalink Reply
Hello,
Our website suddenly started spitting out PHP errors at the top of our site:
Warning: Invalid argument supplied for foreach() in /home/orbitala/public_html/helpers/miser_support/miser_CDNS.php on line 113

We haven't touched the website and we're not sure what caused it. Miser has actually been turned off for months and is still set to
define( 'MISER_ENABLE',FALSE );
in the site.php config file.

Thanks!

I'm not the best at debugging but any help would be much appreciated.
CIRESatCU replied on at Permalink Reply
I'm having problems removing MISER. When I have it installed, it appears to work (I think)...

I want to remove it and when I remove the files from the helpers/ and libraries/ directories, the site blows up and shows white only (I can't do anything, can't log in, etc.)

Any idea what would cause this or what I should look for to fix this back to before I had added the MISER files?

Thanks!
Phallanx replied on at Permalink Reply
Phallanx
@Kiki1597

Sounds like you have errors disabled and left the cache on. Specifically, the overrides cache..

Turn off and delete/clear the cache files then remove the Miser files..
pixel8 replied on at Permalink Reply
pixel8
Hi,

Any plans on making this awesome "add-on" compatible with Concrete5.7 ? :)
Phallanx replied on at Permalink Reply
Phallanx
@pixel8

Well. The new 5.7 asset system is supposed to make Miser obsolete but I expect much of that will be down to whether addon developers use it or not as it seems very manual. Saying that. I haven't heard anything about it since the video some months ago so I'm not even sure if they ended up implementing it..

5.7 isn't robust enough for me to investigate how to hook in to it ATM (and the addon won't work without a lot of effort) but as Miser was designed not to be CMS specific I might look into it if there is a call to do so.
Phallanx replied on at Permalink Reply
Phallanx
@pixel8

Well. I relented and installed 5.7 on a WAMP. Luckily I didn't see any of the installation issues otherwise I would have given up there and then. I then hacked it and got it to call Miser (only requires 3 lines of code, the trick is finding where to put them).

The only issue was with @imports, so I turned off @import combining and it then seemed to work fine with the default theme and blocks (the only things available).

Seems asset management and page layout isn't the main performance issue though as the Time To First Byte is 3-5 times slower than 5.6 (irrespective of Miser).
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi Phallanx,

As someone new to concrete5, this is the first time I've seen Miser. It could not have come at a better time.

I've been thinking a lot about all the view.css and view.js files that blocks litter pages with and all the added HTTP requests. Miser will save me the time of manually merging and minifying all these files by hand. I am surprised that it isn't part of the core (every SEO/Page Speed tester is looking for these optimization steps). When designing for responsive sites, something like Miser (or doing it all by hand) is mandatory - I don't think most people realize how important this is.

Is it possible to list the steps to get it working with 5.7?
Have you reconsidered making a 5.7 addon?

Thank you
Phallanx replied on at Permalink Reply
Phallanx
QUOTE>>
Is it possible to list the steps to get it working with 5.7?
Have you reconsidered making a 5.7 addon?
<<

5.7 is too unstable and has much bigger performance issues than asset management so Miser is likely to be ineffective. So I will not be listing the steps as I do not wish to support 5.7 right now.

Yes I have considered it and no I will not be making a 5.7 addon (at least not in the near future). The addon was the fruit of my own laziness in wanting an interface for my own websites (it came out 1 year after Misers release) and learning how to create addons for Concrete5. There is no upgrade path for my current websites so have no need of a 5.7 addon and have no desire to learn a new API for a software I will not use, especially when Miser doesn't need to be a Concrete5 addon to operate. .

Besides. 5.7 is supposed to include asset management and make Miser obsolete (it's pre-programmed rather than automagic so lets see how many addon developers can actually be bothered to use it).
andrew replied on at Permalink Reply
andrew
As phallanx says elsewhere, the assets system in 5.7. is meant to obviate the need for Miser. Every asset in the core is either minified to start with or marked as minified/combinable, and if you turn on asset caching from the Dashboard cache settings page, they will be minified and combined on the fly. This includes view.css and view.js files. Additionally, themes can mark assets as provided by the theme (in the case of themes built on bootstrap) and the assets with the same handle in the core will not be included. This can also be done with view.js and view.css for block templates. So no longer will you have view.css files from half a dozen blocks included on the page, if your theme provides support for those. Elemental is a good example of one that does.

Yes, developers will have to support the asset system – but this is something that they should want to do, since it provides support for versions of JavaScript/CSS libraries (to deal with including multiple incompatible copies of the same library on the page) and is much less brittle to deal with in the future. (e.g. we can change the name of the jQuery file or move it somewhere and you're not addressing it by filename, but by its handle.)
Phallanx replied on at Permalink Reply
Phallanx
@Andrew
QUOTE>>
As phallanx says elsewhere, the assets system in 5.7. is meant to obviate the need for Miser.
<<

Only took three years :)
Any plans to implement sprite generation in the asset system? (Miser has a plugin for it)
MrKDilkington replied on at Permalink Reply
MrKDilkington
This is excellent news. I will have to test this out.
Phallanx replied on at Permalink Reply
Phallanx
Miser 1.9.3 has been released as of 18/10/2014.

This release supplies fixes an issue with @imports and implements the clean up of the root path that was causing issues with a trailing slash. It also has an update to the readme.txt clarifying the Concrete5 versions supported.

This update is optional.
tobyme replied on at Permalink Reply
Sorry ignore this - i wrote something and finally fixed the problem myself - a JS conflict as ever!
LijnDiensten replied on at Permalink Reply
LijnDiensten
Do you have any experience with the dashboard and system and settings content becoming hidden after installing Miser?
Phallanx replied on at Permalink Reply
Phallanx
@LijnDiensten

Most issues are either that caching was not turned off in the concrete settings or a javascript conflict which can be detected by looking at the browsers development tools error console

If you need to recover because you cannot see the system edit bar etc then you only have to rename or delete the view.php override that you placed in the [ROOT]/libraries directory.
LijnDiensten replied on at Permalink Reply
LijnDiensten
Hi - thanks for the quick reply! I see a 404-error forhttps://cdn.ucb.org.br/Scripts/jquery.backstretch.js,... although that file exists at non-http:http://cdn.ucb.org.br/Scripts/jquery.backstretch.js.... My own site runs on https; could that be the cause?
Phallanx replied on at Permalink Reply
Phallanx
@LijnDiensten
Yes. Add the following to your site.php
define('MISER_USE_CDNS',FALSE);
I'll see if I can find another provider that has both.

Few minutes later........
//cdnjs.cloudflare.com/ajax/libs/jquery-backstretch/2.0.4/jquery.backstretch.min.js
You can either leave CDNs disabled with the define, or update the backstretch CDN entry in "miser_support/miser_CDNS.php" with the above. You will also need to delete the CDNS_cache.txt file in that same directory for the change to propagate.

I'll release an update with that change at the weekend.
LijnDiensten replied on at Permalink Reply
LijnDiensten
Added //cdnjs.cloudflare.com/ajax/libs/jquery-backstretch/2.0.4/jquery.backstretch.min.js - works! :) Thanks a lot.
aptus replied on at Permalink Reply
Hi Phallanx.

Are there fewer bugs in the paid version?
Does the paid version come with support to ensure it works?
And if not, can we get a refund if it doesn't work?

I've been having some issues with the CC version of Miser on our development box. I had to move the "count++" line 670 in miser.php merge_imports() has to move to above line 668 to prevent infinite looping. I'm also seeing an invalid double
</style></style>
end tag in the output, just before the "Sorted by Miser" comment. But the one that's got me stumped are the broken tabs and search button on the blue bookings widget athttp://brokenhill.aptus.com.au/... which should look likehttp://www.brokenhillaustralia.com.au/...

Thanks for providing such an awesome plugin,
Paul
Phallanx replied on at Permalink Reply
Phallanx
@aptus
When you purchase, you are using the same Miser core software (1.9.3 currently with the same bugs, if any) but receive an addon that makes configuring much, much easier (see the picture on SF). When using the addon it is far quicker to identify the causes of issues by turning on and off certain features (like the @import ;) ). However, the reason for a payment is to receive the waiver that allows a site to use the software legally for commercial benefit-the addon is a bonus and not required to use Miser.

I will look into the issues you report,as I always do regardless of whether a payment is made. Of course a payment tends to concentrate the mind and does earn you my undivided attention to your specific problems. However refunds are not possible to due to Google retiring their digital downloads platform this week (yesterday in fact).

A double "</style>" is harmless in and of itself, but unusual and may be symptomatic of an unusually formatted CSS section. Miser is quite good at extracting what it needs from JS and CSS, but can be a little careless when cleaning up unusually formatted sections and it can be fooled (on purpose sometimes).

Considering the number of addons on your page, Miser is doing pretty well if you have left all the settings at their default values. Usually when an addon is not playing, a couple of rules to make Miser ignore its' JS or CSS is sufficient to get it working. Tabbed pages without javascript tend to look like your particular issue - I wouldn't be surprised if the Javscript is missing or in error for some reason.
Phallanx replied on at Permalink Reply
Phallanx
@aptus

Ok. Confirmed the count++ infinite recursion. Below is the fix (which you have already implemented). It's the whole function so it is easy for people to identify and replace.

Protected function merge_imports($contents){
         static $count = 0;
         if ($count > 3) return ($contents);  //Limit depth to 4
         if (stripos($contents,'@import') === FALSE) return $contents;
         $num = preg_match_all( '#@import\s*(?:url\([\'"]?)?(.+?)[\'"\)]?;#i',$contents,$imports);
         if ( $num > 0 ){
            for ($i=0; $i < $num; $i++){
               $url = $this->clean($imports[1][$i]);
               if (stripos($url,"http") !== FALSE) continue;         // Ignore remote calls
               $_contents = $this->get_files(array($url),"#(".$url.")#",TRUE);   
               $contents = str_replace($imports[0][$i],$_contents,$contents);            
            }
            $count++;
            $contents = $this->merge_imports($contents);
         }


I can't replicate your extra style tags, though.
mrjcgoodwin replied on at Permalink Reply
mrjcgoodwin
Hi Phallanx,

I'm just trying your plugin for the first time and it seems to have created a big issue with my site :-/

I'm getting an error message as follows:

Warning: fopen(/server/path/files/cache/js/c54198ed6b9ff7c49cb21e06e2b6343f_merge.js): failed to open stream: No such file or directory in /server/path/public_html/helpers/miser.php on line 729


The dashboard also appears completely blank, although I'm able to navigate directly to the panels if I can find the urls for them.

If I try and remove the Miser files from the library and helper folders it completely borks the site entirely.

I've followed the readme instructions exactly, and have checked the C5 default cache is off and have cleared everything out of the files/cache folder.

Please help!
Phallanx replied on at Permalink Reply
Phallanx
@mrjcgoodwin

That is a warning, not an error so it will not cause PHP to halt - it looks like Miser could not save the Javascript file (permissions?).

Removing or renaming the view.php from the libraries directory will disable Miser *UNLESS* you have overrides cache on then 5.6 will complain it cannot find Miser if you've deleted all the files.

Put all the files back if you have deleted them then add the following to your site.php
define ('MISER_ENABLE',FALSE);

You should then be able to get into the dashboard and uncheck and clear the cache before removing/renaming "view.php"
mrjcgoodwin replied on at Permalink Reply
mrjcgoodwin
Thank you so much - super support :-)

Have checked permissions and all seems fine. The only thing I can think at the moment is it doesn't like running without the domain name set (currently testing the site under the direct server url). Which might be why it's giving file not found type errors.

I'm now waiting for the domain to propagate and I'll see if this fixes this issue and report back. :-)
Phallanx replied on at Permalink Reply
Phallanx
@mrjcgoodwin

Miser works locally from the root ($_SERVER['DOCUMENT_ROOT']). The domain name shouldn't matter but the root entry does as it is the starting point for reading and writing files. If that isn't set at all, you get a warning (was a problem with IIS). If it is set but not pointing to the sites root, then that can cause problems when Miser comes to save and read files,
mrjcgoodwin replied on at Permalink Reply
mrjcgoodwin
Ok - this could be the issue then. As the hosting account is set up with a domain that wasn't yet pointed, so presumably the root is set to the domain name in the server config. I'm sure it will be ok once the dns is sorted, but I'll report back for everyone's future reference once it's done. :-)
mrjcgoodwin replied on at Permalink Reply
mrjcgoodwin
Ok - can confirm pointing the domain fixes the issue, and also install c5 without the domain pointing had meant the default .htaccess rewrite base had gotten a bit screwey too.

Thanks for all your help :-)

P.s. I reckon it might a good idea to put the uninstall/disable instructions as their own section in the readme... to prevent panic lol!

J
mrjcgoodwin replied on at Permalink Reply
mrjcgoodwin
Hi Phallanx,

Ran into a possible bug today - apologies if already reported, but couldn't find the exact same thing anywhere else.

When enabling Miser in 5.6.3 (I think ...left my laptop charger at the office!!) stops the WYSIWYG toolbars in composer from showing and the edit fields show as html view rather than text. I'm guessing this is another issue with Tinymce.

Is there a parameter to disable Miser in edit mode?
Phallanx replied on at Permalink Reply
Phallanx
@mrjcgoodwin

There is no command for just edit mode. If you are having problems like this, then curing the symptom isn't the way forward and will byte you in the arse later.

It is almost always caused by a javascript error (check the debug console). You may have to ignore or reposition a piece of javascript, but once you find and ascertain the nature of the error, it is fairly painless to fix.
mrjcgoodwin replied on at Permalink Reply
mrjcgoodwin
Cool, cheers for the pointers will take a look in the morning and try and figure where the conflict is lying. Rather selfishly I had assumed it was a miser problem as it was only an issue in the back end (composer) not in the theme.
mrjcgoodwin replied on at Permalink Reply
mrjcgoodwin
Ok, back on my computer and you were right - there is a javascript error.

However as far as I can tell this is a conflict with C5 core rather than anything specific to the site.

Getting
Uncaught ReferenceError: $ is not defined
errors, which seem to be thrown from tinyMCE in the composer interface. It looks like every composer field has an inline script with a jquery function, however as Miser is putting the script links at the bottom of the page we are getting this error.
mrjcgoodwin replied on at Permalink Reply
mrjcgoodwin
For the time being I've used a define to stop inclusion of jquery in the optimisation, but seems a shame. Not sure yet the knock-on for speed.

Maybe a good future feature would be to be able to exclude all or some dash panels from optimisation.

Forgive my ignorance if there are ways of doing this - you may have guess I'm no script genius!
Phallanx replied on at Permalink Reply
Phallanx
@mrjcgoodwin

There is some customisation for concrete specific aspects but Miser is not concrete5 specific. It can run on any website with any CMS or even raw HTML. So specific customisations for concrete5 are limited. There is no cure for inline blocking code that has dependencies on other Javascript in the head of the page but we can probably degrade a bit more gracefully.

So. If you find "miser_bridge_C5.php" in the "miser_support" directory and add
$miser->keys_top_head('jquery');


after line 79 so it looks like

$miser->keys_ignore($miser->keys_ga());
$miser->keys_top_head('jquery');
$miser->cookie_override = TRUE;


At least then Miser will still use a CDN serving of JQuery and only apply it when logged in as admin.

In the meantime. I will think about it and see if there is a more elegant solution.
mrjcgoodwin replied on at Permalink Reply
mrjcgoodwin
Super thanks for the advice and help, what you've created is truly great.

I will look at implementing your mods.

:-)
theneptune replied on at Permalink Reply
theneptune
Thanks for this post.
jpcharrier replied on at Permalink Reply
jpcharrier
Hi there,

Great plugin!!!

I do have a question however, I've been testing this on a site I would potentially like to use commercially, however it doesn't seem to be picking up any of our theme js or css and only select js is making its way into the merged js/css.

I'm loading my css (header) and js(footer) like this:
// This gets added
   <script async src="http://ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js"></script>
   <script>
      WebFont.load({
         google: {
            families: ['Flamenco:300,400']
         },
         custom: {
            families: ['FontAwesome'],
            urls: [ 'https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css' ] // NOT added.
         }
      });
   </script>
// These do NOT get added....
<link href='https://fonts.googleapis.com/css?family=Flamenco:400,300' rel='stylesheet' type='text/css'>


What's the best way to go about getting these assets added into the merged css/js?

Thanks!!
Phallanx replied on at Permalink Reply
Phallanx
Miser will not merge off site flies; only files actually located on the server. This is by design and common sense when you consider what a CDN is for and how they improve performance.

If you want Miser to include the contents of off site files; download and place them on your server and make the links to the local copies. Miser will then include them.
jpcharrier replied on at Permalink Reply
jpcharrier
Ok thanks for that, that makes sense.

However, in regards to the local assets that it is NOT adding, how do i get them to be added?
I.e.
<script src="<?= $this->getThemePath(); ?>/assets/js/jquery.fancybox.pack.js"></script>
<script src="<?= $this->getThemePath(); ?>/assets/js/imagesloaded.pkgd.min.js"></script>
<link type="text/css" href="<?= $this->getThemePath(); ?>/assets/css/theme.css" rel="stylesheet">


These assets are local, reside in our themes directory but are not being combined. They are referenced as above (ie our theme is not a package, these are not added via addHeaderItem or addFooterItem). Is that why they are not being picked up by miser?
Phallanx replied on at Permalink Reply
Phallanx
@jpcharrier

If that is in the HTML,source sent to the browser, then you have a problem with your inline PHP code (<?= is no longer valid PHP syntax, try <?PHP)

QUOTE>

These assets are local, reside in our themes directory but are not being combined. They are referenced as above (ie our theme is not a package, these are not added via addHeaderItem or addFooterItem). Is that why they are not being picked up by miser?

<
No. Miser doesn't know about the CMS. It just scrapes the HTML sent to the browser so it can work on any website but If you are not using the CMS to process the inline PHP then the getThemepath function is probably not being called to get the path.
adminEasy replied on at Permalink Reply
Guy's.

I know this thread is pretty old now, but hope you are all still there to help :-)

Installed Miser and ran a quick Pingdom test and was astounded with the 98/100 as opposed to the usual 68/100. That's the good news.

Unfortunately my Slate theme disappeared. Read through the thread - ensured cache was off did the clearing out; still no joy.

Temporarily removed view.php just to get the site looking normal.

Any advice warmly welcomed
tobyme replied on at Permalink Reply
Deeply unhelpful I know, but I loved Miser for a while and then found, for
a reason I never got to the bottom of, on a couple of sites with later
versions of 5.6 I got php errors I couldn't diagnose. They were thrown in
the header and would display on the page somewhat at random.

Unhelpful I know, but just to say I used, was a huge fan but then due to
bugs began to need to revert to the c5 caching which I believe was
significantly imporved by the end of 5.6.

BTW don't just believe all that you read on those scanning sites, it is
clearly hoop jumping, but I have built tiny sites that get a low score just
because I call two JS files and not one and don't use image sprites.

Anyway - unhelpful but just saying.

Good luck
Phallanx replied on at Permalink Reply
Phallanx
@tobyleeming

Knowing there is a problem is 1/2 of the solution. If no-one says anything then nothing needs fixing, right?

I'm not sure what the current version is (haven't been back to concrete for some months now) but I have sites with it running from versions from 5.4 to 5.6.3.3. I've always said that Miser works for 90% of sites out-of-the-box so there are those 10% that need tweaking but they are usually just settings that need applying.
Phallanx replied on at Permalink Reply
Phallanx
@adminEasy

The three usual culprits of theme issues are:.
1. Using getstylesheet instead of getthemepath
2. Heavily nested @imports
3. Position dependant JavaScript.

Miser has quite a few functions so generally when tracking down issues the way to go is to turn off all the features (@import parsing, CDN replacement, CSS/JS merging etc) and turn them on one-by-one until it falls over again (see the readme if you don't have the addon). That should tell you what aspect is causing the issue and you can either decide to just turn leave that off or we can drill in further to find the exact issue if you need to squeeze that extra stoney blood.

Do you have a publicly available address so I can see the issue?
adminEasy replied on at Permalink Reply
Hi All,

Many thanks for the updates.

Phallanx - can you advise on the file(s), that I need to look at here please?

My site ishttp://easyroomlets.com
Phallanx replied on at Permalink Reply
Phallanx
@adminEasy

Difficult to say. I really need to see the what the HTML source looks like with Miser on as well as with Miser off. Save the HTML source to text files for On and off and attach them to your post.

You do seem to have have a lot of position dependant entries for javascript. Don't forget that Miser will strip those out and throw them in a file so any positional dependant javascript needs to be omitted from the optimisation process. Miser is aware of a couple (like google ads) but you may have to tell it about "clicky" (Ignore list)

You also have some IE switches. Miser ignores those but it will move JS and CSS and consolidate them if they are between the switches. The net result is that all the switches end up together so if you are expecting the order to be preserved between normal JS/CSS and your IE switches-they won't be.

Like I said before. You really need to turn on and off the features to find out which particular optimisation(s) is causing the problem. When you can identify which one, we can theorise a resolution based on your source.
adminEasy replied on at Permalink Reply 3 Attachments
Hi Phallanx,

Many thanks for coming back to me so quickly.

Attached are the text files - Miser Off, Miser On and Environment Information.

A steer on where I should look would be helpful before I start dismantling my site.

Cheers
Phallanx replied on at Permalink Reply
Phallanx
@adminEasy
You shouldn't have to touch your site......just get the right settings for it.

There is nothing obvious. No notices or errors (errors were turned on, yes?). Miser seems to have created the CSS and JavaScript files. So if the theme is the issue you need to check that the ?????_merge.css is where it says it is, is readable and that it has your theme CSS in.

Can I also assume you are not getting any JS errors in the browser console?
adminEasy replied on at Permalink Reply
Hi Phallanx,

I'll give it a go tomorrow, and let you know.
adminEasy replied on at Permalink Reply
Hi Phallanx,

Just a quick one - around 6 months ago I migrated my server to a VPS, and now all concrete files sit in /httpdocs - will this cause any issues in the miser files?

Change all the settings and refreshed my site and all was well.

Changed the foillowing back to TRUE
private $endis_all = TRUE; // Enable/disable the helper (becomes transparent)

and the site started to behave as before.
Phallanx replied on at Permalink Reply
Phallanx
@adminEasy

Sounds like it was a cache problem. No fault found :)

I forget that people are still using Miser without the addon. Saying "just turn them off" is a couple of checkboxes for me in the admin screen but I think it means wading through PHP files for you.

If you look in the readme (or even the constructor, as you are already in there) you will find the "defines" to turn them on and off so that you can add to the site.php rather than mess around with the Miser core files.

By the way. Now you have brought me out of my slumber I have checked that it still works with 5.6.3.4 and it seems fine. Let me know when you want to try it on 5.7. It's only a 4 line hack ;)