You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
-
2Possible duplicate of Is it considered bad practice to have PHP in your JavaScriptgnat– gnat07/03/2017 18:10:39Commented Jul 3, 2017 at 18:10
-
@gnat that one asks if it's considered a bad practice. This question asks about design patterns the practice violates, and about specific arguments against the practice, so I think this one builds off the other. Kind of an "is it bad?" "yes - ok, why?" followup.jinglesthula– jinglesthula07/03/2017 18:26:03Commented Jul 3, 2017 at 18:26
-
1The proposed duplicate does answer your "why is this a bad practice?" question: (a) "Try decoupling the two languages by making data their only interface – don't mingle the code." (b) "What you're supposed to do is comprehend what Seperation of Concerns and Progressive Enhancement mean. This basically means you have dynamic HTML and static JavaScript" (c) "escaping inside a javascript context is not as simple as you would hope [...] risk of a XSS bug slipping through" (d) "just for organizational purposes, this can get very annoying. It's bad enough to mix html and php (in my opinion)."amon– amon07/03/2017 18:54:23Commented Jul 3, 2017 at 18:54
-
1You answered your own question when you said, "I could see (and have seen) this willy-nilly mixing get out of hand and create maintenance issues and debugging headaches." This is exactly why it is a bad practice.scriptin– scriptin07/03/2017 18:55:11Commented Jul 3, 2017 at 18:55
-
1+1 Good question and good writing ("the bog of eternal stench" ;))Tulains Córdova– Tulains Córdova07/03/2017 19:44:38Commented Jul 3, 2017 at 19:44
lang-js