2

OK, so I'm using HTML5 Boilerplate to minify css, js and html which is placed within my PHP files.

Using the build script I can successfully create a publish folder and the css and js and even the php code is minified. Good so far.

However, there is a discrepancy with the output specifically single and double quotes in my link tags? For some reason it deals with the first link tag fine and then struggles with the second link tag. As you can imagine this causes significant problems when rendering in the browser.

Here's the code pre-build:

<link rel="stylesheet" href="<?php echo base_url('styles/normalize.css');?>">
<link rel="stylesheet" href="<?php echo base_url('styles/main.css');?>">
<script src="<?php echo base_url('js/vendor/modernizr-2.6.2.min.js');?>"></script>

And then after using the build script. NB. The single quote inserted in the second link tag href.

<link rel="stylesheet" href="http://localhost/styles/normalize.css">
<link rel="stylesheet" href='http://localhost/styles/be5c719.css">
<script src="http://localhost/js/vendor/modernizr-2.6.2.min.js"></script>

It could be argued that I don't need to have the php base_url() function thus keeping it relative, however this shouldn't make a difference should it? Is there something in the configuration files I have missed?

SH_
  • 266
  • 2
  • 3
  • 17
  • "It could be argued that I don't need to have the php base_url() function thus keeping it relative", since baseURL is already relative why wouldn't you do this? It is only causing unnecessary work on the server side. – howderek Mar 01 '13 at 14:12
  • Hmmm. That is rather peculiar... – howderek Mar 01 '13 at 14:34
  • That's a fair point. I ran the code without the PHP base_url() and kept the href's relative. However, as you can see from the code below it has inserted a single quote either side of the second `link` tag and then reverted to double quotes in the following `script` tag. ` ` It renders in the browser fine, but with potential inconsistency in the output of single and/or double quotes, I have some concern. – SH_ Mar 01 '13 at 14:35
  • what are you using to do the do the minify? – Andrew Mar 01 '13 at 15:09
  • I'm using the Ant build script which I believe uses the Closure compiler and the YUI compressor – SH_ Mar 02 '13 at 09:24

1 Answers1

0

If you want matching quotes and are happy removing the echo base_url piece, simply ensure the quotes in the replace in these lines are double instead of single quotes. We were simply inconsistent there and this is the first time it's been pointed out.

https://github.com/h5bp/ant-build-script/blob/master/build.xml#L692-L696

And then please submit a pull request so everyone can have some consistency in their lives. :)

I'm not sure what's happening in your first example. The replace (as you can see) just uses single quotes. If we were mismatching them for everyone there'd be a lot more noise around it. I'll have to test it. Feel free to open an issue on the repo so that I have something to track to.

roblarsen
  • 452
  • 2
  • 7