We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

SL Combinator : Combine and Compress JavaScript and CSS on-the-fly : Version Update (2.1.0) 1st April, 2009

Development and Programming

Tyssen's avatar
Tyssen
756 posts
15 years ago
Tyssen's avatar Tyssen
It looks to me like the problem is that a full URL is being passed to minify, rather than an absolute URL. In other words, if you pass “/css/thingy.css” instead of “http://example.com/css/thingy.css”, it should work.

That’s exactly what I’ve just discovered and so I thought I’d update this thread as I’d read a while back about people having similar issues, but it looks like you beat me to it. I’d been using {site_url}js/script.js and as soon as I took {site_url} out, it worked. 😊

       
Stephen Lewis's avatar
Stephen Lewis
466 posts
15 years ago
Stephen Lewis's avatar Stephen Lewis

Hi Tyssen,

Glad you got it sorted. I also updated the documentation accordingly.

Stephen

       
Craig Allen's avatar
Craig Allen
135 posts
15 years ago
Craig Allen's avatar Craig Allen

Hi.

Is this not able to be used with stylesheets created through templates?

I’ve tried to implement it as follows.

{exp:sl_combinator:combine_css disable="yes" debug="no"}
  <link rel="stylesheet" type="text/css" media="all" href="{stylesheet=styles/layout}" />
  <link rel="stylesheet" type="text/css" media="all" href="{stylesheet=styles/navigation}" />
{/exp:sl_combinator:combine_css}

But this returns the following.

<link href="http://mysite.net/scripts/minifier/index.php?f=http://mysite.net/?css=styles/layout.v.1254258090,http://mysite.net/?css=styles/navigation.v.1254257995" media="all" type="text/css" rel="stylesheet">
1HTTP/1.0 400 Bad Request
</link>
       
Stephen Lewis's avatar
Stephen Lewis
466 posts
15 years ago
Stephen Lewis's avatar Stephen Lewis

Craig,

The URL passed to the plugin needs to be either absolute or relative; full URLs (http://example.com/css/example.css) won’t work.

Cheers, Stephen

       
Matthew Pennell's avatar
Matthew Pennell
221 posts
15 years ago
Matthew Pennell's avatar Matthew Pennell

I’ve got the same problem as Craig, above - URLs created using {stylesheet=""} (for the versioning) generate full URLs, which don’t work with the plugin. But if you switch to just referencing the template (e.g. href=”styles/navigation”) it generates a 400 Bad Request. This is my generated URL:

http://mysite.com/min/index.php?f=c/main.css,styles/my_theme/

When disabled, the output is as follows:

<link rel="stylesheet" type="text/css" href="/c/main.css">
<link rel="stylesheet" type="text/css" href="/styles/my_theme/">

So it looks like the plugin is creating the correct paths, but something is breaking when it tries to combine and compress a template-generated stylesheet.

       
Stephen Lewis's avatar
Stephen Lewis
466 posts
15 years ago
Stephen Lewis's avatar Stephen Lewis

Bloody hell Pennell, I’m beginning to wish I’d never met you :|

I’ve got the same problem as Craig, above - URLs created using {stylesheet=”“} (for the versioning) generate full URLs, which don’t work with the plugin. But if you switch to just referencing the template (e.g. href=“styles/navigation”) it generates a 400 Bad Request.

Have you tried using absolute paths when referencing the template directly? If that still causes you problems, I’ll have to do some digging.

Cheers, Stephen

       
Matthew Pennell's avatar
Matthew Pennell
221 posts
15 years ago
Matthew Pennell's avatar Matthew Pennell
Have you tried using absolute paths when referencing the template directly?

Isn’t that what my second code example is using? Or do I have a different definition of “absolute” than you do?

       
Stephen Lewis's avatar
Stephen Lewis
466 posts
15 years ago
Stephen Lewis's avatar Stephen Lewis
http://mysite.com/min/index.php?f=c/main.css,styles/my_theme/

I’d assumed from this code that you’re using relative paths. Reading your previous message again I’m not so sure… are you using absolute paths in the link elements, resulting in the above output?

Stephen

       
Matthew Pennell's avatar
Matthew Pennell
221 posts
15 years ago
Matthew Pennell's avatar Matthew Pennell

Okay, here are the various things I’ve tried and their rendered HTML/output:

Current, working version, but only minifies the static file

{exp:sl_combinator:combine_css disable="no" debug="no"}
  <link rel="stylesheet" type="text/css" href="/c/explorermagazine.css">
{/exp:sl_combinator:combine_css}
<link rel="stylesheet" type="text/css" href="{path="styles/issue_theme"}">

Output is:

<link rel="stylesheet" type="text/css" media="all" href="http://explorermagazine/min/index.php?f=c/explorermagazine.css" />
<link rel="stylesheet" type="text/css" href="http://explorermagazine/styles/issue_theme/">

Now, let’s try just moving that code into the plugin

{exp:sl_combinator:combine_css disable="no" debug="no"}
  <link rel="stylesheet" type="text/css" href="/c/explorermagazine.css">
  <link rel="stylesheet" type="text/css" href="{path="styles/issue_theme"}">
{/exp:sl_combinator:combine_css}

Output, page is broken (CSS not loaded at all):

<link rel="stylesheet" type="text/css" media="all" href="http://explorermagazine/min/index.php?f=c/explorermagazine.css,{path=" />

Might just need a tweak to a regular expression?

Try it without the domain, just using an absolute path to the template_group/template

{exp:sl_combinator:combine_css disable="no" debug="no"}
  <link rel="stylesheet" type="text/css" href="/c/explorermagazine.css">
  <link rel="stylesheet" type="text/css" href="/styles/issue_theme/">
{/exp:sl_combinator:combine_css}

Output (CSS not loaded):

<link rel="stylesheet" type="text/css" media="all" href="http://explorermagazine/min/index.php?f=c/explorermagazine.css,styles/issue_theme/" />

Looks like it should be okay, but that URL actually returns a 400 Bad Request.

       
Stephen Lewis's avatar
Stephen Lewis
466 posts
15 years ago
Stephen Lewis's avatar Stephen Lewis

Thanks for the detailed response Matthew.

I think I’m going to have to take a more in-depth look at the various ways people are using this addon. As is typical with these things, I built something that worked (and continues to work) for me, and released it because I thought others might find it useful too.

Said others then went and did all manner of things I wasn’t expecting.

Anyway, the short answer is that I don’t have a short answer. Sorry for the lack of solution, but I think this requires a bit more work on my part.

Cheers, Stephen

       
Matthew Pennell's avatar
Matthew Pennell
221 posts
15 years ago
Matthew Pennell's avatar Matthew Pennell

Cool - I’ll have a poke around too and let you know if I get it working for my situation.

       
jorlee90's avatar
jorlee90
7 posts
15 years ago
jorlee90's avatar jorlee90

Are there plans to make this great plugin MSM compatible? It currently works great on my main EE domain but I get invalid request for site B.

       
Stephen Lewis's avatar
Stephen Lewis
466 posts
15 years ago
Stephen Lewis's avatar Stephen Lewis

Hi jlee,

Are there plans to make this great plugin MSM compatible? It currently works great on my main EE domain but I get invalid request for site B.

There’s a simple workaround for this:

  1. In the extension settings, specify the path to the min folder using the {site_url} variable. For example {site_url}utils/min/.
  2. Copy the min folder over to site B, keeping the same folder structure as on site A. Continuing with the above example, it would be in a utils directory in the web root.
  3. You’re done.

Cheers, Stephen

       
Ryan Blaind's avatar
Ryan Blaind
168 posts
15 years ago
Ryan Blaind's avatar Ryan Blaind

Hey Stephen. I am having an issue with the 400 bad request error currently. I am trying to run a css template through the plugin, and it’s coming up with the error. All of the other files I am running through it are working fine, however not this specific stylesheet. My guess is maybe because it’s an EE Template, and not just a flat file.

Here is the line of code that I am using to run it on this file:

{exp:sl_combinator:combine_css disable="no" debug="no"}
<link rel="stylesheet" type="text/css" media="screen" href="{stylesheet=_globals/boilerplate}" />
{/exp:sl_combinator:combine_css}

However it isn’t working. The rendered code looks like this:

<link rel="stylesheet" type="text/css" media="screen" href="http://skinbeautiful.ca/scripts/min/index.php?f=http://skinbeautiful.ca/?css=_globals/boilerplate.v.1259755397" />

however with sl combinator turned on I am getting a 400 bad request when I try to load that generated url.

any help would be greatly appreciated. should I try the basepath setting in the minify script possibly?

       
Stephen Lewis's avatar
Stephen Lewis
466 posts
15 years ago
Stephen Lewis's avatar Stephen Lewis

Hi Ryan,

All of the other files I am running through it are working fine, however not this specific stylesheet. My guess is maybe because it’s an EE Template, and not just a flat file.

That would be my guess too. It’s a clearly a problem for a number of people, so I need to spend some time looking into this. In other words, I don’t have a quick fix, sorry.

should I try the basepath setting in the minify script possibly?

I don’t think that’s the issue, because you’re not (as far as I’m aware) attempting to serve a file that is outside the server’s DOCUMENT_ROOT. By all means give it a whirl, but I can’t think what you’d need to set it to.

Cheers, Stephen

       
First 4 5 6 7 8

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.