0

I've added to the theme (twenty ten) a php template file in which I've written some javascript code.
I then created a new page and set it to use that template.
Then I installed and activated the 'wp-minify' plugin hoping for it to drop the blanks and comments.
But when I look at the page's source code in the browser I see the code regularly.
Your advice will be appreciated.

1

As far as i understand WP Minify plugin works on scripts and styles that are included in your page <head> tag as external files and not scripts and style that are in the <body> tag.

if you are inserting scripts and style in the <body> tag manully you should insert it after you minify it and you can use many of the free online minify tools

  • my code resides in the head tag but is internal. Why is it better to pre-minify the code then using a plugin which will automate things for me? – Ash Jun 3 '11 at 16:02
  • I'm not saying its better but its a solution because the plugin works in a way that doesn't work for you obviously, an alternative would be to create your code in an external file and include it (which is a preferred way SEO wise). – Bainternet Jun 3 '11 at 16:23
  • the online minify tools did a better job for me than the plugin so I'm gonna stick with them. It's a shame though, since the plugin doesn't touch the js code. It only changes the served html. And also, it minifies automatically. With the online tools I have to do it manually after each code change and I have to keep a copy of the code. Still, the result is better. And thanks for the SEO tip. – Ash Jun 4 '11 at 20:18
0

I assume it's because your js is inline and not a .js file.

  • my js is indeed inline, but I can't find in the plugin's documentation a note saying the js should be external to be minified. – Ash Jun 3 '11 at 16:01
  • @Ash the documentation doesn't mention it but if you check out the plugin's code you will see just who it works. – Bainternet Jun 3 '11 at 16:24
  • Actually, I now see that it did work on my inline code. It just didn't do a very good job. Only the space line are gone. Comments still left in and no other spaces were removed. I'll do it with one of the online tools. – Ash Jun 4 '11 at 20:10
  • Also, If you want to minify external code using wp-minify you should state so in the plugin's advanced settings. I couldn't make it work, though. – Ash Jun 4 '11 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.