unemployment Posted June 8, 2011 Share Posted June 8, 2011 I'm not sure what to do here... Do I let php do the work or do I let JavaScript do the work with my news feed. Right now I have a pre of... [0] => Array ( [id] => 1 [firstname] => Sam [lastname] => ran [username] => s [industry] => [stage] => [companyid] => [companytag] => [gender] => 1 [accounttyperaw] => 1 [accounttype] => d [country] => 230 [state] => [city] => Old [approveddate] => 1307537300 [feedid] => 1 [feedfirstname] => Sam [feedlastname] => g [feedusername] => g [action_id] => usercountry [details] => 230 [display_name] => fjfj [associate_name] => fjjfj [avatar] => /assets/img/avatars/users/jafkfkfkio.png [message] => You have updated your location to United Kingdom. ) message is a new array field which I created to just include the message generated by the row. This is currently generated in PHP. The problem is that sometimes message would say... Sam G has updated his location to United Kingdom where Sam G is a link to his profile page. In that case, the [message] section would include a link in the array. [message] => <a href="">Sam G</a> has updated his location to United Kingdom. Should I have the php create the structure like this or should I try and have javascript do it? Quote Link to comment https://forums.phpfreaks.com/topic/238779-let-php-do-the-work-or-let-javascript-do-the-work/ Share on other sites More sharing options...
Philip Posted June 9, 2011 Share Posted June 9, 2011 Let PHP do the work. PHP will (almost) always be quicker, and by far more reliable. YOU control the way PHP is setup vs depending on someone's browser config and if they even allow JS. Quote Link to comment https://forums.phpfreaks.com/topic/238779-let-php-do-the-work-or-let-javascript-do-the-work/#findComment-1227256 Share on other sites More sharing options...
fugix Posted June 9, 2011 Share Posted June 9, 2011 kingphillip is right, server response is quicker and does not depend on browser configuration. One question, why are you using <pre> tags for this? Quote Link to comment https://forums.phpfreaks.com/topic/238779-let-php-do-the-work-or-let-javascript-do-the-work/#findComment-1227258 Share on other sites More sharing options...
unemployment Posted June 9, 2011 Author Share Posted June 9, 2011 kingphillip is right, server response is quicker and does not depend on browser configuration. One question, why are you using <pre> tags for this? I only use pre to show what was in my array in a readable format. I don't actually use it on my site. Quote Link to comment https://forums.phpfreaks.com/topic/238779-let-php-do-the-work-or-let-javascript-do-the-work/#findComment-1227260 Share on other sites More sharing options...
Anti-Moronic Posted June 22, 2011 Share Posted June 22, 2011 There are pros and cons of using either. PHP will work regardless of the browser, PHP will likely be faster (but that doesn't mean it will *seem* faster to the client). This is important, although PHP will be parsed faster, it will not seem that way to the client if you, for example, use AJAX. If you use PHP to change some text on a page based on a value in a cookie, you really think that will be faster than using javascript to do the same thing? Not at all. JS will win in speed just because it is directly parsed by the browser in real time, even if the actual parsing takes longer. So, if you don't mind sacrificing some independence, use Javascript. Then if need be, use PHP as well. Don't forget, using PHP will also put stress on the server. Won't matter to most but when you're dealing with enterprise applications it is extremely important you don't waste resources processing something the browser can process. Quote Link to comment https://forums.phpfreaks.com/topic/238779-let-php-do-the-work-or-let-javascript-do-the-work/#findComment-1233546 Share on other sites More sharing options...
Adam Posted June 23, 2011 Share Posted June 23, 2011 Don't forget, using PHP will also put stress on the server. Won't matter to most but when you're dealing with enterprise applications it is extremely important you don't waste resources processing something the browser can process. You have that wrong. I work in an enterprise-level company; first and foremost concern (for this kind of issue) is that the functionality will work for every user, regardless of their browser. This means for any JS solution you would have to provide a PHP solution anyway. There's also a time issue in companies like mine, so if a combined PHP & JS implementation would take too long it simply wouldn't be a requirement (unless specifically requested). Of course performance is an issue, but with internal core processes where the performance would have a large impact. Quote Link to comment https://forums.phpfreaks.com/topic/238779-let-php-do-the-work-or-let-javascript-do-the-work/#findComment-1233789 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.