Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-27-2013, 02:13 AM
mathforum mathforum is offline
 
Join Date: Nov 2005
Posts: 165
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Combining javascript in header

Has anyone successfully done this before? I know in theory that referencing .js files to grab in the header will slow down page loading time a lot, and vB4 has a bunch of them. Can I simply stack the source codes on top of each other and load that one .js file instead?

Any recommendations on a program to use for this?
Reply With Quote
  #2  
Old 10-27-2013, 02:26 AM
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Jul 2009
Location: USA
Posts: 10,929
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This may get you going in the right direction, e360-Additional JavaScript Template
Reply With Quote
Благодарность от:
mathforum
  #3  
Old 10-27-2013, 03:07 AM
mathforum mathforum is offline
 
Join Date: Nov 2005
Posts: 165
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for the quick reply! That's not exactly what I need but it probably can be used at some point so I'll make note of it.

I can't say it's completely due to vB since I probably have some add-ons in there too, but the header portion of the code is a mess and renders terribly slower than it should. Each reference to a .js file and .css slows down the load time or completely stops it momentarily. This has been confirmed by several page load tests online.

The way to improve this, I hope, is to aggregate the code into 1 file so the HTTP header requests go down and the whole thing downloads at once, then more quickly moves on to the rest of the code.

Here is Google's suggestion:
Quote:
Remove render-blocking JavaScript:
http://yui.yahooapis.com/combo?2.9.0...nection-min.js
http://mathhelpboards.com/clientscri...-core.js?v=420
http://mathhelpboards.com/mobiquo/sm...r/appbanner.js
http://mathhelpboards.com/clientscri...arker.js?v=420
http://yui.yahooapis.com/2.9.0/build...n-min.js?v=420
http://mathhelpboards.com/clientscri...debar.js?v=420
http://cdn.mathjax.org/mathjax/lates...til=configured
http://mathhelpboards.com/clientscri...n_md5.js?v=420
Optimize CSS Delivery of the following:
http://fonts.googleapis.com/css?family=Passion+One
http://fonts.googleapis.com/css?family=Wellfleet
http://fonts.googleapis.com/css?family=Francois+One
http://mathhelpboards.com/clientscri...s?d=1382833520
http://mathhelpboards.com/mobiquo/sm.../appbanner.css
http://mathhelpboards.com/clientscri...s?d=1382833520
http://mathhelpboards.com/clientscri...s?d=1382833520
http://mathhelpboards.com/clientscri...s?d=1382833520
http://mathhelpboards.com/clientscri...s?d=1382833520
http://mathhelpboards.com/clientscri...s?d=1382833520
http://mathhelpboards.com/css.php?st...additional.css
That is the list of files I want to merge. Then I'm hoping I can just delete the individual references in the template and reference the one large .js file and the rest will work like it did before.

I haven't found any record of someone doing this though here or at vbulletin.com, or anywhere else on Google although it's been mentioned many times.
Reply With Quote
  #4  
Old 10-27-2013, 03:27 AM
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Jul 2009
Location: USA
Posts: 10,929
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I guess the best thing is to try it, see if everything works first, then run a speed test to see if there is a difference.
Reply With Quote
  #5  
Old 10-27-2013, 03:43 AM
mathforum mathforum is offline
 
Join Date: Nov 2005
Posts: 165
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Will do hopefully If anyone has tips on the easiest way to do this I'm still all ears. It's great to have another way to optimize vB after years and years of reading through all the ways.
Reply With Quote
Благодарность от:
CAG CheechDogg
  #6  
Old 10-27-2013, 10:33 AM
CAG CheechDogg's Avatar
CAG CheechDogg CAG CheechDogg is offline
 
Join Date: Feb 2012
Location: Riverside, California USA
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I tried combining all the js files into one and there were problems because not every js file is needed at load time. I did exactly what you did, combine it all into one file for just one http request but it just didn't work.

If you do find a way to do this, please let us know my Man. I go back to it every once in a while to see if I can manage to come up with a solution, but nothing....sigh... GOOD LUCK !
Reply With Quote
2 благодарности(ей) от:
mathforum, RedTurtle
  #7  
Old 10-27-2013, 01:15 PM
mathforum mathforum is offline
 
Join Date: Nov 2005
Posts: 165
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by CAG CheechDogg View Post
I tried combining all the js files into one and there were problems because not every js file is needed at load time. I did exactly what you did, combine it all into one file for just one http request but it just didn't work.

If you do find a way to do this, please let us know my Man. I go back to it every once in a while to see if I can manage to come up with a solution, but nothing....sigh... GOOD LUCK !
Did you combine all or just the js files from the header? We definitely don't want to load more than we have to in the head portion of the code, if the script can be dynamically run in the body somehow. I posted a list of the js files that my site is referencing now which could be optimized somehow - in total 8 files. I can only really combine the ones locally hosted so I'll try that today and see if going from 8 to 3 files makes any difference.
Reply With Quote
Благодарность от:
RedTurtle
  #8  
Old 10-27-2013, 03:48 PM
final kaoss final kaoss is offline
 
Join Date: Apr 2006
Posts: 1,314
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What you can do is run the plugin vbsupercharged and use it to combine js. Also what I've done is use the defer element on all but these scripts.
Code:
http://www.video-game-chat.com/forum/clientscript/vbulletin-core.js?v=421 (43.5KiB)
http://www.video-game-chat.com/forum/clientscript/vbulletin_md5.js?v=421 (5.2KiB)
http://www.video-game-chat.com/forum/clientscript/vbulletin_read_marker.js?v=421 (3.3KiB)
http://www.video-game-chat.com/forum/clientscript/jquery.lazyload.mini.js (2.5KiB)
http://www.video-game-chat.com/forum/ (2.4KiB of inline JavaScript)
http://www.video-game-chat.com/forum/forumrunner/detect.js (1.6KiB)
http://www.video-game-chat.com/forum/clientscript/sc_thumbs.js (1017B)
http://www.video-game-chat.com/forum/ajax.php?do=analytics&v=421 (1005B)
Reply With Quote
Благодарность от:
mathforum
  #9  
Old 10-27-2013, 04:11 PM
mathforum mathforum is offline
 
Join Date: Nov 2005
Posts: 165
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi final_kaoss. Thank you for writing but as I see in that thread the mod is no longer working for vB 4.1+ and I'm running 4.2.0 right now so I don't think it will work.

Can you explain more about the defer script and how you discovered the scripts which are essential to load in the head versus not essential?
Reply With Quote
  #10  
Old 10-27-2013, 04:24 PM
final kaoss final kaoss is offline
 
Join Date: Apr 2006
Posts: 1,314
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's still working just fine. I'm using it on 4.2.2

Also I just found out by trial & error which ones not to do that to. You can learn more about deferring here.
http://gtmetrix.com/defer-parsing-of-javascript.html
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:17 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05355 seconds
  • Memory Usage 2,275KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (6)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete