carefree Posted August 16, 2007 Share Posted August 16, 2007 I have about 8 javascipt src files included in my template and its slowing its down the whole site heaps. Is there a way I can speed it up??? <SCRIPT language=javascript src="http://www.site.com/js/script.js"></SCRIPT> Quote Link to comment https://forums.phpfreaks.com/topic/65192-solved-speed-up-javascript-sources/ Share on other sites More sharing options...
NArc0t1c Posted August 16, 2007 Share Posted August 16, 2007 Short and simple - No. Edit: It may be you're javascripting, try removing some. Quote Link to comment https://forums.phpfreaks.com/topic/65192-solved-speed-up-javascript-sources/#findComment-325515 Share on other sites More sharing options...
Orio Posted August 16, 2007 Share Posted August 16, 2007 Nothing to do with php. The only thing I can suggest you is optimizing your javascripts. Orio. Quote Link to comment https://forums.phpfreaks.com/topic/65192-solved-speed-up-javascript-sources/#findComment-325517 Share on other sites More sharing options...
carefree Posted August 16, 2007 Author Share Posted August 16, 2007 Dang!! Thought there might have been a way :'( Quote Link to comment https://forums.phpfreaks.com/topic/65192-solved-speed-up-javascript-sources/#findComment-325520 Share on other sites More sharing options...
tibberous Posted August 16, 2007 Share Posted August 16, 2007 Delete 6 of them. Honestly, what do you need that much javascript for? There has to be some you can delete. Quote Link to comment https://forums.phpfreaks.com/topic/65192-solved-speed-up-javascript-sources/#findComment-325521 Share on other sites More sharing options...
carefree Posted August 16, 2007 Author Share Posted August 16, 2007 Yeah I could possibly replace 2 or 3 of the with php Im also using: <? include "http://www.site.com/inc/top.php" ; ?> Will these slow down the site also?? Quote Link to comment https://forums.phpfreaks.com/topic/65192-solved-speed-up-javascript-sources/#findComment-325522 Share on other sites More sharing options...
carefree Posted August 16, 2007 Author Share Posted August 16, 2007 Ok heres one I could replace - a simple onclick popup window can this be converted to php?? <!-- function Start(page) { OpenWin = this.open(page, "CtrlWindow","toolbar=No,menubar=No,location=No,scrollbars=No,resizable=No,status=No,width=200,height=200,left=150,top=150,"); } //--> Quote Link to comment https://forums.phpfreaks.com/topic/65192-solved-speed-up-javascript-sources/#findComment-325525 Share on other sites More sharing options...
Orio Posted August 16, 2007 Share Posted August 16, 2007 PHP is not client side, its server side. It does different things than javascript. Orio. Quote Link to comment https://forums.phpfreaks.com/topic/65192-solved-speed-up-javascript-sources/#findComment-325551 Share on other sites More sharing options...
carefree Posted August 16, 2007 Author Share Posted August 16, 2007 Server side = Faster. So if i convert all the javascripts to php It should work Quote Link to comment https://forums.phpfreaks.com/topic/65192-solved-speed-up-javascript-sources/#findComment-325562 Share on other sites More sharing options...
NArc0t1c Posted August 16, 2007 Share Posted August 16, 2007 Server side = Faster. So if i convert all the javascripts to php It should work I think what Orio was trying to say is that php won't be able to make popus and alerts, etc. Quote Link to comment https://forums.phpfreaks.com/topic/65192-solved-speed-up-javascript-sources/#findComment-325564 Share on other sites More sharing options...
gurroa Posted August 16, 2007 Share Posted August 16, 2007 I have about 8 javascipt src files included in my template and its slowing its down the whole site heaps. Is there a way I can speed it up??? Yes. You can atleast join them into one script. <?php // joinscript.php // optionally disable cache Header("Pragma: no-cache"); Header("Cache-Control: no-cache"); Header("Expires: ".GMDate("D, d M Y H:i:s")." GMT"); function GetCont($file) { if (file_exists($file)) { $arr = explode("\r\n", file_get_contents($file)); $retarr = array(); reset($arr); while(list(,$l) = each($arr)) { $l = trim($l); if (!empty($l)) $retarr[] = $l; } return "\n".implode("\n", $retarr)."\n"; } } echo GetCont('./first_script.js'); echo GetCont('./second_script.js'); ?> To call such joining use <script type="text/javascript" language="JavaScript1.2" src="joinscript.php"></script> Quote Link to comment https://forums.phpfreaks.com/topic/65192-solved-speed-up-javascript-sources/#findComment-325565 Share on other sites More sharing options...
Orio Posted August 16, 2007 Share Posted August 16, 2007 Man you just don't get my point... You can't use PHP to pop up windows, show alert messages, and use other events like in javascript. PHP's output is just plain html / javascript (or whatever) sent to the user. PHP and javascript just do different things. Orio. Quote Link to comment https://forums.phpfreaks.com/topic/65192-solved-speed-up-javascript-sources/#findComment-325566 Share on other sites More sharing options...
carefree Posted August 16, 2007 Author Share Posted August 16, 2007 Yes that worked. It loads within 1 or 2 seconds now Quote Link to comment https://forums.phpfreaks.com/topic/65192-solved-speed-up-javascript-sources/#findComment-325572 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.