Forums/General Categories/Development

Developing Your First App: Tips, Tricks and Advice

SiteApps Team
posted this on April 05, 2011 17:19

General tips

  • The SiteApps javascript call may be anywhere on the website - thus consider situations where the call may be before the <BODY> tag and some objects you may refer to are not yet created.
TIP: You can use jQuery to make sure that all elements have loaded.  Here's an example of how to do this:

jQuery(document).ready(function() {  
  // do stuff
});

 

  • Be careful with variables: sometimes you may create or use variables that could be used elsewhere on the page.  Whenever possible create variables within functions - and if you do need global variables, use a terminology that would avoid conflicts.

 

  • SiteApps uses asynchronous Javascript calls.  Therefore, certain commands, such as document.writeln() will not work.  Do always test your app in development to make sure the asynchronous calls don't your app.
TIP: You can use jQuery to add content to the webpage instead of using document.writeln().  Here's an example of how to append code using jQuery:

Instead of:
document.writeln('<div id="newdiv">your code</div>');
do this:
var code_to_add = '<div id="newdiv">your code</div>';
jQuery(code_to_add).appendTo('body');

 

  • We do suggest testing your app on various sites.  If your app targets a specific audience (ex: bloggers) make sure you test your app on the different platforms available.

 

  • If you are using the auto-implementation of jQuery - do make sure you call your scripts from an external file.  Because these fuctions will already be included in a function scope.

Optimizing your Javascript code

 

When you talk about site loading performance, every byte counts.  Do consider optimizing your code to load as quick as possible.  Below are some tips on how to minimize code size:

  • use short variable names: try to avoid big variable names, but do consider that global variables may conflict with your app code.
  • use functions: whenever possible, use functions to repeat actions that would require longer code.
  • declare short variables: if possible, create short variables that can represent calls to specific objects, example: var d=document;.

 

excl.png Consider using a Javascript compression tool.  Below are some suggestions: 

 

Other great reads regarding performance and optimization:

 

IMPORTANT NOTE:  SiteApps is not responsible for errors or conflicts the suggestions above may cause to your code.

 

 

 

Other resources

 

Use Marketing on your app's page in the marketplace

 

 

People still do judge a book by it's cover.  When you submit your app do make sure to submit pretty icons and attractive screen captures.  Also spend some time being descriptive about your app and what problem it solves.  This is specially important for paid apps.