Do you have some feature in mind that you'd love to see in Couch? Let us know.
13 posts Page 1 of 2
To speed up page loading time something like the following for css and js files might come in handy. I know I can do that by hand but it would be perfect to have such a tool included.

Code: Select all
<cms:combine-css>
<link rel="stylesheet" href="<cms:show k_site_link />font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="<cms:show k_site_link />css/normalize.min.css">
<link rel="stylesheet" href="<cms:show k_site_link />css/nivo-lightbox.css">
<link rel="stylesheet" href="<cms:show k_site_link />css/pushy.css">
<link rel="stylesheet" href="<cms:show k_site_link />stylesheets/screen.css">
</combine-css>


what du you think?
? :)
Code: Select all
<html>
<head>
<style>
   <cms:embed '1.css' />
   <cms:embed '2.css' />
   <cms:embed '3.css' />
   <cms:embed '4.css' />
</style>
<body>
no :) I want all css files combined into one single file.

I used this code for css, not sure if thats optimal. I'm not a coding pro - found this snippet somewhere and it's working so far

Code: Select all
<?php
header("Content-type:text/css");
echo
file_get_contents("normalize.min.css")."\r\n".
file_get_contents("nivo-slider.css")."\r\n".
file_get_contents("themes/default/default.css")."\r\n".
file_get_contents("main.css")."\r\n".
file_get_contents("nav.css")."\r\n".
file_get_contents("lightbox.css")."\r\n";
?>


but this way the css get's not minimised, but better then loading 6 files?
Where do you put this snippet in?
it actually doesent matter, you can use it directly in your head too. I use it in a snippet named styles.php and get it into pages with <cms:embed 'styles.php'/>.

but as written I would love to have a couch tag for that to use it for css and js
cl wrote: no :) I want all css files combined into one single file.

I used this code for css, not sure if thats optimal. I'm not a coding pro - found this snippet somewhere and it's working so far

Code: Select all
<?php
header("Content-type:text/css");
echo
file_get_contents("normalize.min.css")."\r\n".
file_get_contents("nivo-slider.css")."\r\n".
file_get_contents("themes/default/default.css")."\r\n".
file_get_contents("main.css")."\r\n".
file_get_contents("nav.css")."\r\n".
file_get_contents("lightbox.css")."\r\n";
?>


but this way the css get's not minimised, but better then loading 6 files?


Seems like this is just an embedded snippet. You can change the file_get_contents to embed tags, put all the css in the snippet folder. In fact you can turn this entire file to couch code:

Code: Select all
<cms:content_type 'text/css' />

<cms:embed 'normalize.min.css' />
<cms:embed 'nivo-slider.css' />
<cms:embed 'themes/default/default.css' />
<cms:embed 'main.css' />
<cms:embed 'nav.css' />
<cms:embed 'lightbox.css' />


Let me know if that doesn't work, or doesn't achieve what you'd like.
As for minify-ing files via couch, unfortunately there is no feature/addon to do this yet. Perhaps something we can look for in the future. I would look more into it but I am currently waiting for the next release of couch before I continue looking into addon development :)
Image
Thought you might be interested in these two other threads relating to this topic.

viewtopic.php?f=3&t=7703
viewtopic.php?f=2&t=8599

I took Musman's recommendation and have been using Koala (http://koala-app.com/). Among other things, it can minify and concatenate your CSS and JS files.

https://github.com/oklai/koala/wiki/JS- ... nd-combine
thank you, I will try that. I used Koala before but mostly for sass
Hi there.
I found a php code snippet to combine and minimise css. No need on Sass or Koala, it's done on load.
http://www.webdesign-klamonfra.de/codeschnipsel/css-dateien-zusammenfassen.php.

Is it possible to create a cms tag out of it?

Code: Select all
<?php
  header('Content-type:text/css; charset=utf-8');
  header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
  function get_remote_file($url) {
    if (function_exists('curl_init')) {
      $c = curl_init($url);
      curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($c, CURLOPT_HEADER, 0);
      $file = curl_exec($c);
      curl_close($c);
      return $file;
    }
    else {
      die('Error');
    }
  }
 
  // CSS-Dateien zusammenfassen
  $content = get_remote_file('www.webdesign-klamonfra.de/css/reset.css');
  $content .= get_remote_file('www.webdesign-klamonfra.de/css/style.css');
  $content .= get_remote_file('www.webdesign-klamonfra.de/css/hinweis.css');
  $content .= get_remote_file('www.webdesign-klamonfra.de/css/print.css');
  $content .= get_remote_file('.../css/codeschnipsel.css');
 
  // Kommentare entfernen
  $content = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $content);
 
  // Tabs, Leerzeichen und Zeilenumbrüche entfernen
  $content = str_replace(array("\r\n","\r","\n","\t","\s"),"", $content);
 
  // letztes Semikolon, Leerzeichen nach Doppelpunkt und
  // Leerzeichen vor Klammer entfernen
  $content = str_replace(array(";}",": "," {"),array("}",":","{"),$content);
 
  // Ausgabe der zusammengefassten CSS-Datei
  echo $content;
 
  // Leert den Ausgabe-Puffer und deaktiviert die Ausgabe-Pufferung
  ob_end_flush();
?>
It is pretty basic and could become a part of my <cms:rel /> tag :) However I don't have time at all to implement it at the moment.
13 posts Page 1 of 2

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 1 guest

cron