Skip to main content
Software Engineering

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*

Draft saved
Draft discarded
Cancel
11
  • 2
    Possible duplicate of Is it considered bad practice to have PHP in your JavaScript Commented 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. Commented Jul 3, 2017 at 18:26
  • 1
    The 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)." Commented Jul 3, 2017 at 18:54
  • 1
    You 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. Commented Jul 3, 2017 at 18:55
  • 1
    +1 Good question and good writing ("the bog of eternal stench" ;)) Commented Jul 3, 2017 at 19:44

lang-js

AltStyle によって変換されたページ (->オリジナル) /