Load Time: PHP vs. External JavaScript File
Posted: Thu Apr 03, 2008 11:47 am
I manage a number of web site and am attempting to centeralize some of common by frequently updated content and images. Because this content needs to be somewhat personalized for user groups, I am envisioning a Google Adsense like application (however no where near as complex).
I have two options:
One is to use an external javascript file sitting on a centeralized server. This external javascript file would pull in additional configuration files, also sitting on the server, that are related to the page URL (and additional personalization parameters) requesting the javascript file.
Second, and preferred, method would be to use a php script to use parameter passed in the URL string to dynamically generate configured javascript which would be returned to the browser just as the external_file.js would.
My Question
How much additional load time (insignificant, moderate, signifiant) will the php option require?
- If it uses xml files (on the php server) for configuration data
- If it uses MySQL database for configuration data
Obviously using the PHP enable some of my content serving logic to be cloaked compared to javascript. Plus changes and updates would be much easier to manage compared to constantly generating and regenerating the javascript files...but is it worth it.
Thanks
I have two options:
One is to use an external javascript file sitting on a centeralized server. This external javascript file would pull in additional configuration files, also sitting on the server, that are related to the page URL (and additional personalization parameters) requesting the javascript file.
Code: Select all
<script type="text/javascript" src="http://central_server.com/external_file.js"></script>Code: Select all
<script type="text/javascript" src="http://central_server.com/external_script.php?site_id=3"></script>How much additional load time (insignificant, moderate, signifiant) will the php option require?
- If it uses xml files (on the php server) for configuration data
- If it uses MySQL database for configuration data
Obviously using the PHP enable some of my content serving logic to be cloaked compared to javascript. Plus changes and updates would be much easier to manage compared to constantly generating and regenerating the javascript files...but is it worth it.
Thanks