Welcome! To use this support forum, please Login or Join Today!

   

Errors for Minify CSS & JS

{name}
Rank

Total Posts: 30

Joined 2012-03-03

PM

 

Casey,

I’m running a Mobius child theme and have minified both CSS and JS files per this previous topic. The parent theme’s style.css has been copied into the child theme’s style.css.

This time, however, I’m getting 404 errors returned for CSS and JS. My child theme’s functions.php is: http://hastebin.com/bukemafiri.php

Have I missed something? Any help is greatly appreciated!

{name}
RankRankRankRank

Total Posts: 3667

Joined 2011-04-27

PM

 

It looks like hastebin is deleting entries lately. Can you repost the link to pastebin or something else? Also, do you have a URL to the site in question?

{name}
Rank

Total Posts: 30

Joined 2012-03-03

PM

 

Hi Casey,

Apologies for the delay. Here are the proposed edits to my Mobius child theme’s functions.php linked via Pastebin. The parent theme’s style.css has been copied in its entirety to the child theme. I used this version of the /min installed via FTP to my site’s root folder. I’m also using 1200px skeleton selected via the theme options panel.

http://pastebin.com/fQgD6NL6

If I try to run this to minify CSS and JS, all CSS styles are stripped from the theme and both CSS and JS return 404 errors. The site’s URL is behind a maintenance plugin for another week or so, but I’ll be able to post it soon if you need it.

In the meantime, is there anything that stands out as incorrect? Would renaming my child theme’s folder have any adverse effects?

Any thoughts are greatly appreciated.

{name}
RankRankRankRank

Total Posts: 3667

Joined 2011-04-27

PM

 

I ran into a few problems. $wpsite was not defined so I added $wpsite = site_url(); to each function (st_header_scripts and st_registerstyles).

Where you have $minpath.’/b=wp-content/themes I had to change to $minpath.’/b=mobius/wp-content/themes because I’m running in a subdirectory, but that may not be your case.

In the case above, I also had to use:
RewriteBase /mobius/min
in my /min/.htaccess

{name}
Rank

Total Posts: 30

Joined 2012-03-03

PM

 

Casey, thanks so much for looking into this. I’m working on a new installation next week and will test this early, prior to building it out. I’ll let you know how it performs.

Really appreciate the continued–and exceptional–support. Cheers!

{name}
Rank

Total Posts: 30

Joined 2012-03-03

PM

 

Casey,

I’ve forgotten where we left off with this as I can’t see the code snippets in previous comments, but the following PHP works well for minifying core CSS and JS in Mobius.

Just posting here for reference.

In my case, I’m using the latest version of minify, the 1400px version of Skeleton and some additional jQuery script in “custom-scripts.js”.

http://hastebin.com/lirehibeji.php

<?php

/*-----------------------------------------------------------------------------------*/
// Register and Minify Core Styles and Javascript
/*-----------------------------------------------------------------------------------*/

 
function st_registerstyles() {
 $minpath 
'/min';
 
$child_theme str_replace(site_url().'/wp-content/themes/'''get_bloginfo('stylesheet_directory'));
 
$parent_theme str_replace(site_url().'/wp-content/themes/'''get_bloginfo('template_directory'));
 
$preset_style of_get_option('layout_style');
    
 
$minify = array(
  
$parent_theme.'/css/formalize.css',
  
$parent_theme.'/css/flexslider.css',
  
$parent_theme.'/css/skeleton-1400.css',
  
$parent_theme.'/css/animate-custom.css',
  
$parent_theme.'/css/prettyphoto.css',
  
$parent_theme.'/layout.css',
  
$child_theme.'/style.css',
  
$child_theme.'/'.$preset_style.'.css'
 
);
 
$stylesheets join','$minify );
 
 
wp_enqueue_style('theme-styles'$wpsite.$minpath.'/b=wp-content/themes&amp;f='.$stylesheetsNULLNULLNULL'screen, projection');
}
 
add_action
'wp_enqueue_scripts''st_registerstyles');

 
function 
st_header_scripts() {
 $minpath 
'/min';
 
$child_theme str_replace(site_url().'/wp-content/themes/'''get_stylesheet_directory_uri());
 
$parent_theme str_replace(site_url().'/wp-content/themes/'''get_bloginfo('template_url'));
    
 
$minify = array(
  
$parent_theme.'/javascripts/jquery.cycle.min.js',
  
$parent_theme.'/javascripts/superfish.js',
  
$parent_theme.'/javascripts/jquery.formalize.min.js',
  
$parent_theme.'/javascripts/jquery.flexslider.js',
  
$parent_theme.'/javascripts/jquery.backstretch.min.js'
  
$parent_theme.'/javascripts/jquery.prettyphoto.js',
  
$child_theme.'/js/custom-scripts.js'
 
);
 
$javascripts join','$minify );
 
 
wp_enqueue_script('javascript'$wpsite.$minpath.'/b=wp-content/themes&amp;f='.$javascripts, array('jquery'),$version,true);
}
 
add_action
'wp_enqueue_scripts''st_header_scripts');

?>