Timeline for Escape <?php … ?> on javascript file
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 2, 2018 at 9:33 | vote | accept | Mthe beseti | ||
Jun 28, 2014 at 12:15 | comment | added | kojiro | But the browser doesn't care if the filename ends in ".js", so perhaps it's clearer and easier to tell the application server to render ".js.php" files and leave static js alone. (The important thing is the mime type returned in the response.) | |
Jun 27, 2014 at 10:40 | comment | added | Pronto | I agree that it's not a good practice, I just pointed out that it's possible to add dynamic stuff to .js files. I wouldn't do it myself unless pressed. .phtml is almost always the correct way to do it. | |
Jun 27, 2014 at 9:55 | comment | added | Emi | @Pronto I think this solution is better than yours :) .js files are cached by browsers and can be minified. Also you can have something like Varnish in front of the web server or use a CDN to provide resources like js, css, images. And only forward requests that need php processing to the web server. | |
Jun 27, 2014 at 9:33 | comment | added | Mthe beseti | I will add it back to the .phtml. I was going to use ajax though but i'm not that pro with it | |
Jun 27, 2014 at 9:20 | comment | added | Pronto | Not really, because this is not gow PHP has been usually set up and you must have root level access to configuration files. But it's one solution and it might be acceptable way for people who know what they are doing :) | |
Jun 27, 2014 at 9:17 | comment | added | Marius♦ | @Pronto. Huh? I never knew that. But is it a good idea to do it? | |
Jun 27, 2014 at 9:14 | comment | added | Pronto | Well, actually you can, however you need to configure your web server / PHP to parse .js files as well. It's simple to set up, but it's by no means a standard out of the box configuration. | |
Jun 27, 2014 at 9:09 | history | answered | Marius♦ | CC BY-SA 3.0 |