Custom Javascript

This feature is use at your own risk. We cannot provide technical support for issues with custom Javascript.

It's possible to add custom Javascript to your app by uploading a .js file in your app customizer settings. This file will then be loaded into your app. This feature is not available for all plans.

It's important to know a few things first:

  1. We do not offer support for custom code. If your code breaks your app, you have to fix it.
  2. You cannot use jQuery, Angular, or any other library, just plain Javascript.
  3. Keep it simple. It's not a good idea to be writing complex scripts, it may produce unexpected results.
  4. Custom Javascript should be tested in a development build from PhoneGap Build. It will not run in the web preview or preview app correctly.

Video Tutorial

How to use this feature

First you'll need to write a custom javascript file. We recommend you write your code in a self-executing anonymous function like this:

( function() {

// your code here


You can only use plain Javascript, no jQuery or Angular. We have a helper function named "ready" that is important to use. You are adding normal Javascript into an Angular environment, so your code will not execute the same way as a normal webpage. Using our "ready" function, you can always make sure your elements are loaded before manipulating them.

Here is some example code:

// Put your custom code inside this anonymous function
( function() {

	// use this custom ready function to make sure your element is available
	ready('#clickMe', function(element) {

	    var el = document.getElementById('clickMe');

		el.addEventListener('click', function() {'', '_blank');


	// Here's another example of using the native social sharing
	ready('#clickMeToo', function(element) {

		var el2 = document.getElementById('clickMeToo');

		el2.addEventListener('click', function() {
		  window.plugins.socialsharing.share('My custom message');



Notice we are using the "ready" helper function to check if the element is loaded before doing anything with it. We recommend you copy the above code into your own file, make edits, and save.

In the code above we are referencing elements with an ID of "clickMe." To make that do something, we created a custom HTML page, and added a button with that ID like this:

<button id="clickMe" ion-button>Click Me</button>

Now when that custom page is loaded, and that button is clicked, it will execute our code.

Here's another example displaying an app rate dialog.

( function() {

	// use this custom ready function to make sure your element is available
	ready('ion-content', function(element) {

	    setTimeout( function() {
		    // you must include cordova-plugin-apprate in your custom config for this to work
		    if( typeof AppRate != "undefined" ) {

				AppRate.preferences = {
					displayAppName: 'My app',
					usesUntilPrompt: 3,
					useLanguage: null,
					simpleMode: true,
					promptAgainForEachNewVersion: false,
					inAppReview: true,
					storeAppURL: {
						ios: '',
		}, 5000 );


For the app rate code above to work, you must add the app rate plugin to your custom config. Visit your app builder, go to the Settings tab, scroll down to Phonegap config.xml custom code, and add this line:

After adding your custom Javascript file as described below, and the plugin for app rate, rebuild your app and test on a device. Note that app ratings will show a dialog in test mode, but you cannot rate the app unless you are on the app store.

Uploading Your Custom Javascript File

Visit your app customizer, click the Settings tab, and scroll down to Custom Javascript. Upload your .js file, do not zip the file.

Save your app and rebuild, and you will be able to test your code in the browser preview. Remember that device features such as social sharing only work on a device.

Interacting with WordPress

Your custom Javascript file is added into the app files, which are not a part of WordPress. Your custom Javascript can interact with your app menu, toolbar, custom HTML pages, and API list pages. It is not meant to interact with WordPress pages.

To run custom Javascript on your WordPress pages, you can use a  child theme and enqueue the script there.