The idea is, if a user is accessing our site from China, we've got to block certain assets to improve our site speed. (For example, Facebook resources. I need to block them from even trying to load, because they'll always come back as blocked)
The caveat is that I have to do it in JavaScript (update: see edit at bottom), because it must be done client-side due to our caching with Akamai.
Consider this HTML with some JSTL:
<div class="num1">
//some stuff like text and images
<div class="num2">
//a nested div with other stuff
<c:if test="${varIsAlwaysTrue eq false}">
<div class="num3">
</div>
</c:if>
</div>
</div>
How do I put something like an IF statement around that, which uses a JavaScript variable? (The variable is called XY.isChina)
All I can really think of is what would be the scriptlet approach: (instead of the <% tags and Java code, obviously)
<script>
if (XY.isChina === false) {
</script>
<div class="num1">
//some stuff like text and images
<div class="num2">
//a nested div with other stuff
<c:if test="${varIsAlwaysTrue eq false}">
<div class="num3">
</div>
</c:if>
</div>
</div>
<script>
}
</script>
I'm almost positive that won't work.
The object of the game here is that none of that stuff within the IF statement loads. Making holes on the page is acceptable, but if it's possible for responsive elements to treat it like it's not even there (for alignment purposes) then that's even better.
Any thoughts?
Thanks in advance.
EDIT: I should have said that I need to do it client-side instead of specifying JavaScript in particular. The variable is already set in JavaScript, but if there are other client-side methods to doing this, that's fine. I cannot, however, use libraries like jQuery.