I am wondering if there is any way to detect if a browser supports javascript on the web server (--> javascript = enabled) before the actual response is sent back to the browser?
How to Detect Serverside if a Browser supports Javascript before Sending Initial Webserver Response?
Asked
Active
Viewed 539 times
1
-
1By using – v1r00z Oct 10 '14 at 13:31
-
No, I mean detect it server side, just from the request of the browser... – electronix384128 Oct 10 '14 at 13:32
-
3Not reliably. There's nothing in the HTTP protocol about JavaScript support (unsurprisingly). What are you actually trying to achieve? – Pointy Oct 10 '14 at 13:35
-
I doubt that it can be done using only the server side, but you can tell if the browser supports javascript like in php : http://php.net/manual/en/function.get-browser.php $js_capable = get_browser(null, true)=>javascript == 1 The other way is using javascript to set a variable in your form data and check if it was set in the server side.. if yes then javascript did set it.. – v1r00z Oct 10 '14 at 13:42
-
@Pointy I need to distinguish between users who don't have javascript (or disabled) and the ones that have javascript. Based on that I want to serve a different html file. – electronix384128 Oct 10 '14 at 14:05
-
1Well why not just serve one file that has appropriate content for browsers with and without JavaScript enabled? That's what's generally done. Or, you can serve the page that expects JavaScript with a redirect `` tag inside a ` – Pointy Oct 10 '14 at 14:23
1 Answers
0
After some more research I found out that it is actually impossible to detect Javascript on the initial request web server side.
The actual reason for getting to know if that would be possible is that I wanted to create a solution where the web server serves different content based on javascript availability.
I have described my solution for retina images here: http://blog.benmarten.me/best-way-to-optimize-website-images-for-all-possible-retina-sizes/

electronix384128
- 6,625
- 11
- 45
- 67