Javascript compression

Rate this topic: Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.1.00 out of 6 based on 1 vote(s)
GK User
Fri Aug 23, 2013 12:21 am
Reply with quote
Report this post
Hi,

I'm trying to activate Javascript compression but I have not been able to do. I'm looking all related thread of Gavick Forum to this problem and nothing looks like work for me.

I spent a lot of hours optimizing my website, minimizing the number of resources, improving loading time, configuring the server properly, modifying php code for best results, using pagespeed Google service... I use different tools to check response time and SEO grade (althought this is relative), and all these tools always said me "You should reduce the number of javascript files". I'm going crazy looking the correct way to compress javascript files but is impossible to me.

I'm a bit desperate and would be very very grateful that someone could help with my problem.

Best regards.

www.juguetitossex.es
User avatar
Senior Boarder

GK User
Fri Aug 23, 2013 10:31 am
Reply with quote
Report this post
If you have many extensions the JS maybe be loaded after template compression engine so maybe you should look at JCH optimize extension.
User avatar
Platinum Boarder

GK User
Fri Aug 23, 2013 11:33 pm
Reply with quote
Report this post
Hi bkrztuk,

I've been trying compressing javascript files using JCH optimizer but the result is practically the same. I even exluded all extensions from javascript compressing, or modules only or files like k2.js but next error are displayed:

Uncaught ReferenceError: jQuery is not defined

This error repeats in many lines. Althought I've tried loading jQuery from local copy in K2 and Virtuemart components, but nothing changes (in K2 with different versions of jQuery).

I don´t know what else to do.
User avatar
Senior Boarder

GK User
Mon Aug 26, 2013 8:19 am
Reply with quote
Report this post
Probably one of your 3rd party extensions use some external jQuery which may be not downloaded from remote servers because of php curl function limitations etc. Please check K2 settings to load jQuery from local not remote copy. Probably VirtueMart don't have this kind of feature so you can try to disable jQuery there or just exclude jQuery library from cache.
User avatar
Platinum Boarder

GK User
Mon Aug 26, 2013 2:17 pm
Reply with quote
Report this post
Hi,

I think I've found what the problem, at least the main problem. In head.php file of my template there are some javascript code embedded:

Code: Select all
<script type="text/javascript">
var $K2 = jQuery.noConflict();
</script>
<script type="text/javascript">
      var JCaption=new Class({initialize:function(a){this.selector=a;$$(a).each(function(a){this.createCaption(a)},this)},createCaption:function(a){var f=document.createTextNode(a.title),c=document.createElement("div"),d=document.createElement("p"),e=a.getAttribute("width"),b=a.getAttribute("align");if(!e)e=a.width;b||(b=a.getStyle("float"));if(!b)b=a.style.styleFloat;if(b==""||!b)b="none";d.appendChild(f);d.className=this.selector.replace(".","_");a.parentNode.insertBefore(c,a);c.appendChild(a);a.title!=
""&&c.appendChild(d);c.className=this.selector.replace(".","_");c.className=c.className+" "+b;c.setAttribute("style","float:"+b);c.style.width=e+"px"}});
</script>


But, how I can exclude javascript code of head.php? Or that I can do to fix it?
User avatar
Senior Boarder

GK User
Tue Aug 27, 2013 8:43 am
Reply with quote
Report this post
You can't. This is part of code generated (probably by K2) and added to header section right from component code.
User avatar
Platinum Boarder


cron