brown2005 Posted June 30, 2006 Share Posted June 30, 2006 echo"<SCRIPT language='JavaScript' type='text/javascript' src='$config_url/include/scripts/functions.js'></SCRIPT>";echo"<SCRIPT language='JavaScript' type='text/javascript' src='$config_url/include/scripts/pops.js'></SCRIPT>";hi,instead of using a line like above for the two scripts can i have one line sayecho"<SCRIPT language='JavaScript' type='text/javascript' src='$config_url/include/scripts/all.js'></SCRIPT>";and in the all.js import both of the top scripts.... Quote Link to comment https://forums.phpfreaks.com/topic/13295-importing-js-files/ Share on other sites More sharing options...
cmgmyr Posted June 30, 2006 Share Posted June 30, 2006 Why don't you just combine the 2 scripts into 1? Quote Link to comment https://forums.phpfreaks.com/topic/13295-importing-js-files/#findComment-51216 Share on other sites More sharing options...
brown2005 Posted June 30, 2006 Author Share Posted June 30, 2006 well i could, but it is easier to keep it seperated into different files for easier access for changes or using on different websites.. etc... Quote Link to comment https://forums.phpfreaks.com/topic/13295-importing-js-files/#findComment-51219 Share on other sites More sharing options...
cmgmyr Posted June 30, 2006 Share Posted June 30, 2006 What you could do is have a js.php file the 2 echos in it, then include the js.php into your main file. Quote Link to comment https://forums.phpfreaks.com/topic/13295-importing-js-files/#findComment-51222 Share on other sites More sharing options...
nogray Posted July 3, 2006 Share Posted July 3, 2006 I would go with the PHP solution to write out the <script> tags, but if you want javascript only, you can make an importer file like this[code] var inc = new Array("file1.js","file2.js","file3.js"); var sc = "script"; for(i=0; i<inc.length; i++){ document.write("<"+sc+" language='javascript' src='"+inc[i]+"'></"+sc+">"); }[/code]and include that file in the header section. Quote Link to comment https://forums.phpfreaks.com/topic/13295-importing-js-files/#findComment-52539 Share on other sites More sharing options...
cmgmyr Posted July 3, 2006 Share Posted July 3, 2006 yeah, thats a good idea too Quote Link to comment https://forums.phpfreaks.com/topic/13295-importing-js-files/#findComment-52660 Share on other sites More sharing options...
Jim from Oakland Posted July 4, 2006 Share Posted July 4, 2006 I have a php app that generates a form that "imports" a lot of js scripts, conditionally, depending on needs. I use the file_get_contents function to load content of the js files into a php var which is then appended to the html content. Make sure that any necessary <script> tags are in the "js" files. Works great!Jim Quote Link to comment https://forums.phpfreaks.com/topic/13295-importing-js-files/#findComment-52976 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.