jQuery vs. PHP - Performance Comparison

后端 未结 8 711
猫巷女王i
猫巷女王i 2021-01-15 06:37

Performance-wise, which would be the better solution? Here\'s a really small example. The PHP script returns a number to jQuery, which needs to be checked if it\'s 1

相关标签:
8条回答
  • 2021-01-15 07:03

    Doesn't matter, really - the performance bottlenecks are likely to be elsewhere.

    I would prefer doing this on the server, as supporting non-JS browsers is important again (what with underpowered mobile devices, web spiders and whatnot).

    0 讨论(0)
  • 2021-01-15 07:06

    I don't really think it's a question of speed (although PHP is likely to be faster unless it's running on a very slow server and the client machine is incredibly fast), it's more a question of what's more appropriate.

    In this instance, I'd go for PHP as there's really no reason for this change to be made in the browser, once the page (and jQuery, etc.) has loaded.

    As a general piece of advice - unless you're attempting to add value to the "default" (i.e.: JavaScript free) user experience by using additional "decorations" (such as slideshows, etc.) that gracefully degrade, do it on the server.)

    0 讨论(0)
提交回复
热议问题