Changes between Version 1 and Version 2 of Ticket #58517, comment 20
- Timestamp:
- 09/22/2023 09:56:19 PM (2 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #58517, comment 20
v1 v2 5 5 Yep, there are some "philosophical differences" here about what is considered a "good way" to do things with HTML and what is not a good idea or a "bad way". 6 6 7 I have no doubt that @dmsnell will make the parsing of HTML in PHP work as well as possible, and with the least amount of edge cases. However the popular belief (not just mine but of many developers for many years) is that it is impossible to account for all edge cases. This will always be inferior to applying the same changes from JS using the browser's DOM. The difference being that PHP can only guess but actually has no idea what the DOM will look like once the browser parses the HTML. 7 I have no doubt that @dmsnell will make the parsing of HTML in PHP work as well as possible, and with the least amount of edge cases. However the popular belief (not just mine but of many developers for many years) is that it is impossible to account for all edge cases. This will always be inferior to applying the same changes from JS using the browser's DOM. The difference being that PHP can only guess but actually has no idea what the DOM will look like once the browser parses the HTML. (This also includes subtle browsers differences in handling cases of "broken HTML, etc.) 8 8 9 9 In these terms I'll continue to advocate against using this (or any other) "processing of HTML as string in PHP" in WP core, now and in the future. This would include cautioning/negative reviews for any code that uses this. I believe this is the inferior way to manipulate the HTML, and that using the browser's DOM will always be the better alternative.