progressive enhancement on the server side?
-
23-08-2019 - |
Question
Currently many of the links on our pages get changed to href="javascript:void(0);"
on pageload, but if you're impatient (as most users are) you can click the links before the page loads and land on the clunkier, non-javascript, non-ajax pages.
I'm thinking about progressive enhancement a lot these days, and I predict the majority of our users will have javascript enabled (no data yet, we havn't yet launched alpha)
Is it a bad idea to generate some indicator that a user has javascript enabled for the session, and then serve pages that assume javascript? (ie. have the server put href="javascript:void(0);"
from the start)
Solution
Why not just do this?
<a href="oldversion.htm" onclick="...something useful......; return false;">link</a>
return false
tells the browser not to carry on to the url in the href.
Now js visitors get fancy js, and non-js users fall back silently; and there is no need for changing links on pageload.
OTHER TIPS
Do you do your progressive enhancement on load? You could try to move it to (a cross-browser version of) DOMReady.
Couldn't you delegate this to the document, to keep your HTML clean?
For example, in jQuery:
$( document )
.click( function(){ return false })
.ready( function(){ $( this ).unbind( "click" ) } )