Jump to content

[SOLVED] Speed up Javascript sources <SCRIPT></SCRIPT>


carefree

Recommended Posts

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,");
}
//-->

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.