Javascript Development on a Live Site
Thu, May. 26, 2011If you are doing javascript development on a live site, it is sometimes hard to do testing without your users seeing this testing happening. Recently I have been using a handy little function that allows me to add #dev to the url and only test those functions if the hash is in the url, such as http://www.zedsaid.com/home#dev.
/**
* Take functions out of global scope
*
* @version $Revision: 0.1
*/
var zs = {};
/**
* Checks if we are in dev mode
*
* @version $Revision: 0.1
*/
zs.dev = function(){
var h = document.location.hash.replace('#', '');
return (h && h == 'dev');
}//end
Then when you are ready to do some work and need to test in "dev" mode just use it in an if statement:
if (zs.dev()) {
// Do something here
}//end
Very simple and very useful.
Add Comment