Copy link to clipboard
Copied
We are trying to execute a cfinclude determined by screen width on our responsive website. This if for determining the number of ads that will appear on the page (we want to show a fixed number on screens of 700px or less). We are using Cold Fusion 9 so we can't utilize CF 11's detectDevice function. We realize we can't just use media queries to show or hide the appropriate cfinclude because this will not prevent CF from loading unnecessary ads in the background, it will just hide them and our page speed will be affected. Is Javascript the only way to do this? If so, can someone provide an example without Jquery?
I would suggest either learning javascript or better yet, learn javascript and incorporate a responsive framework like bootstrap 3. Trust me, maintaining width specific include modules on the server will rapidly become a nightmare for you or whoever inherits the project.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
We are novices when it comes to javascript. We see plenty of examples on how to determine width with javascript but we're not sure what exactly we are doing with that information; how we are showing cfinclude 1 for 700px or less and cfinclude 2 for everything else. We were hoping there was another way to do this with just Cold Fusion (9).
Copy link to clipboard
Copied
I would suggest either learning javascript or better yet, learn javascript and incorporate a responsive framework like bootstrap 3. Trust me, maintaining width specific include modules on the server will rapidly become a nightmare for you or whoever inherits the project.
Copy link to clipboard
Copied
It seems to me like you are trying to use a server side process to do something that belongs in the UI. As Steve suggests, you should really get a better understanding of JS and handle the issue there.
Copy link to clipboard
Copied
Thank you for your time.
Copy link to clipboard
Copied
There is a way to do it in ColdFusion 2018.
<cfclientsettings detectDevice=true />
<cfclient>
<cfif cfclient.properties.width lte 480>
Be aware that the Adobe documentation has a typo "cfclient.width" leaving the "properties" out.