Page Index Toggle Pages: 1
Topic Tools
Hot Topic (More than 10 Replies) Minify JavaScript? (Read 4,888 times)
Chess Publishing
Full Member
***
Offline



Posts: 120
Minify JavaScript?
Dec 25th, 2010 at 12:07am
Post Tools
Is it possible to combine the various JavaScript files and then call just this one file to improve the Forum performance? Undecided
  
Back to top
WWW  
IP Logged
 
Chess Publishing
Full Member
***
Offline



Posts: 120
Re: Minify JavaScript?
Reply #1 - Dec 26th, 2010 at 3:15pm
Post Tools
Or what about using individual minified versions of each js file? Here is a minified version of AJS_fx.js, for instance:

Code
Select All
AJS.fx={_shades:{0:"ffffff",1:"ffffee",2:"ffffdd",3:"ffffcc",4:"ffffbb",5:"ffffaa",6:"ffff99"},highlight:function(c,b){var a=new AJS.fx.Base();a.elm=AJS.$(c);a.options.duration=600;a.setOptions(b);AJS.update(a,{increase:function(){if(this.now==7){c.style.backgroundColor="#fff"}else{c.style.backgroundColor="#"+AJS.fx._shades[Math.floor(this.now)]}}});return a.custom(6,0)},fadeIn:function(c,a){a=a||{};if(!a.from){a.from=0;AJS.setOpacity(c,0)}if(!a.to){a.to=1}var b=new AJS.fx.Style(c,"opacity",a);return b.custom(a.from,a.to)},fadeOut:function(c,b){b=b||{};if(!b.from){b.from=1}if(!b.to){b.to=0}b.duration=300;var a=new AJS.fx.Style(c,"opacity",b);return a.custom(b.from,b.to)},setWidth:function(c,b){var a=new AJS.fx.Style(c,"width",b);return a.custom(b.from,b.to)},setHeight:function(c,b){var a=new AJS.fx.Style(c,"height",b);return a.custom(b.from,b.to)}};AJS.fx.Base=new AJS.Class({init:function(a){this.options={onStart:function(){},onComplete:function(){},transition:AJS.fx.Transitions.sineInOut,duration:500,wait:true,fps:50};AJS.update(this.options,a);AJS.bindMethods(this)},setOptions:function(a){AJS.update(this.options,a)},step:function(){var a=new Date().getTime();if(a<this.time+this.options.duration){this.cTime=a-this.time;this.setNow()}else{setTimeout(AJS.$b(this.options.onComplete,this,[this.elm]),10);this.clearTimer();this.now=this.to}this.increase()},setNow:function(){this.now=this.compute(this.from,this.to)},compute:function(b,a){var c=a-b;return this.options.transition(this.cTime,b,c,this.options.duration)},clearTimer:function(){clearInterval(this.timer);this.timer=null;return this},_start:function(a,b){if(!this.options.wait){this.clearTimer()}if(this.timer){return}setTimeout(AJS.$p(this.options.onStart,this.elm),10);this.from=a;this.to=b;this.time=new Date().getTime();this.timer=setInterval(this.step,Math.round(1000/this.options.fps));return this},custom:function(b,a){return this._start(b,a)},set:function(a){this.now=a;this.increase();return this},setStyle:function(b,a,c){if(this.property=="opacity"){AJS.setOpacity(b,c)}else{AJS.setStyle(b,a,c)}}});AJS.fx.Style=AJS.fx.Base.extend({init:function(a,c,b){this.parent();this.elm=a;this.setOptions(b);this.property=c},increase:function(){this.setStyle(this.elm,this.property,this.now)}});AJS.fx.Styles=AJS.fx.Base.extend({init:function(a,b){this.parent();this.elm=AJS.$(a);this.setOptions(b);this.now={}},setNow:function(){for(p in this.from){this.now[p]=this.compute(this.from[p],this.to[p])}},custom:function(c){if(this.timer&&this.options.wait){return}var b={};var a={};for(p in c){b[p]=c[p][0];a[p]=c[p][1]}return this._start(b,a)},increase:function(){for(var a in this.now){this.setStyle(this.elm,a,this.now[a])}}});AJS.fx.Transitions={linear:function(a,e,f,g){return f*a/g+e},sineInOut:function(a,e,f,g){return -f/2*(Math.cos(Math.PI*a/g)-1)+e}};script_loaded=true;script_loaded=true; 

  
Back to top
WWW  
IP Logged
 
Unilat
Development Team
Theme Team
****
Offline



Posts: 1,047
Location: Columbus Ohio, USA
Re: Minify JavaScript?
Reply #2 - Dec 26th, 2010 at 5:55pm
Post Tools
The second would be the only way to make it faster, and barely at that. The first would not help because not all of the javascript files are required on each page and so putting them all together would make each page have to evaluate all of the javascript whether it was needed or not. Making the files as they are now smaller would just make them harder to read and write for us devs.
  
Back to top
 
IP Logged
 
Chess Publishing
Full Member
***
Offline



Posts: 120
Re: Minify JavaScript?
Reply #3 - Jan 2nd, 2011 at 3:53pm
Post Tools
OK, I've tried making a minified combined.js file and deleted most of the calls anyway to see what happens!
No, of course it makes the files much harder to read for humans, they look a complete mess!
  
Back to top
WWW  
IP Logged
 
genghis
Junior Member
**
Offline



Posts: 84
Re: Minify JavaScript?
Reply #4 - Sep 23rd, 2011 at 12:08am
Post Tools
I run another forum software in addition to YaBB, and they have the choice to run Javascript from the server or to let Google handle the javascript "calls" (Is that that right word?) Enabling Google to handle it there sped it up quite a bit. I was wondering if it could be an option in YaBB.
  
Back to top
 
IP Logged
 
Derek Barnstorm
Support Team
YaBB Next Team
Development Team
Beta Testers
****
Offline



Posts: 1,269
Location: United Kingdom

None
Re: Minify JavaScript?
Reply #5 - Sep 23rd, 2011 at 12:40am
Post Tools
Hi,

Google doesn't have YaBB's JavaScript so it wouldn't be possible. I'm assuming the other forum software uses a JavaScript library such as JQuery which can be hosted on Google if you choose to do so.

http://code.google.com/apis/libraries/

And a little reading why it would speed it up (if you're interested):

http://encosia.com/3-reasons-why-you-should-let-google-host-jquery-for-you/

But YaBB doesn't use any such libraries.
« Last Edit: Sep 23rd, 2011 at 12:44am by Derek Barnstorm »  
Back to top
 
IP Logged
 
liuvincent19
YaBB Newcomer
*
Offline



Posts: 4

YaBB 2.6.1
Re: Minify JavaScript?
Reply #6 - Oct 4th, 2011 at 3:00am
Post Tools
The first would not help because not all of the javascript files are required on each page
  
Back to top
 
IP Logged
 
JonB
YaBB Administrator
YaBB Next Team
Operations Team
Beta Testers
Support Team
*****
Offline



Posts: 3,981
Location: Land of the Blazing Sun!

YaBB 2.6.1
Re: Minify JavaScript?
Reply #7 - Dec 21st, 2011 at 11:22am
Post Tools
Off-Topic replies have been moved to this Topic.
  

I find your lack of faith disturbing.
Back to top
IP Logged
 
Dandello
YaBB Administrator
YaBB Next Team
Operations Team
Beta Testers
Support Team
*****
Offline



Posts: 2,434
Location: Earth

YaBB 2.6.1
Re: Minify JavaScript?
Reply #8 - Dec 21st, 2011 at 3:05pm
Post Tools
And then we have the people who add their own javascripts for various and sundry things.
  

If you only have one solution to a problem you're not trying hard enough!
Back to top
WWW  
IP Logged
 
JonB
YaBB Administrator
YaBB Next Team
Operations Team
Beta Testers
Support Team
*****
Offline



Posts: 3,981
Location: Land of the Blazing Sun!

YaBB 2.6.1
Re: Minify JavaScript?
Reply #9 - Dec 21st, 2011 at 11:59pm
Post Tools
Indeed Dandello - such as 'seasonal snow' or 'village scenes' in my case...

Cool
« Last Edit: Dec 21st, 2011 at 11:59pm by JonB »  

I find your lack of faith disturbing.
Back to top
IP Logged
 
Dandello
YaBB Administrator
YaBB Next Team
Operations Team
Beta Testers
Support Team
*****
Offline



Posts: 2,434
Location: Earth

YaBB 2.6.1
Re: Minify JavaScript?
Reply #10 - Aug 10th, 2012 at 8:57pm
Post Tools
This Topic was moved here from Non-YaBB Programming and Technical Help [move by] Dandello.
  

If you only have one solution to a problem you're not trying hard enough!
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Topic Tools
 
  « Board Index ‹ Board  ^Top