This article lists a few tips that can help you improve the performance of the Discount Ninja script in your store:

How we optimize for performance

We take performance very seriously at Discount Ninja. We understand good performance leads to a positive user experience and increased potential for conversion. We also understand performance scores help with Google ranking. Our team of engineers continuously strives to improve performance where possible.

Discount Ninja requires CSS (styling) and JavaScript (logic) to provide discount functionality. Both the CSS and JavaScript have been heavily optimized to avoid impact on your site and optimize performance:

  • CSS is loaded asynchronously from Shopify's CDN and is cached by the browser.

  • CSS is minified to minimize the impact on bandwidth.

  • JavaScript is minified and served Gzipped to minimize the impact on bandwidth, it is also cached by the browser.

  • JavaScript loads asynchronously, which means your page renders first. This further reduces the impact of the script on the perceived load speed of your site.

Tools such as Shopify's speed score and Google PageSpeed Insights may mark (part of) Discount Ninja's assets as "unused JavaScript / CSS". During an automated speed test, only a portion of the logic of the app will be used which leads some tools to believe that the script is partially unused. This is incorrect.

Tip 1: Set script mode to "Asset mode"

Discount Ninja supports two script modes: tag and asset mode. They represent different mechanisms to include and load the Discount Ninja script on your store. This setting is by far the most important setting with regards to performance.

There are some key differences between the two script modes you should be aware of before switching:

Tag mode

Asset mode

Script load time









Asset mode is typically faster because it allows the Discount Ninja script to load first (after your page has rendered). This ensures the app isn't waiting for other apps that may be blocking the browser or executing slowly.

However, in asset mode, you'll need to manually remove the script from your theme if you ever need to uninstall the app. If you uninstall the app via the Settings > Subscription > Cancel plan button, the app will automatically do this for you.

The script mode can be configured from the menu in the app.

Go to Settings > General > Installation status:

Next, click "Switch to asset mode":

Tip 2: set up Dynamic Pricing for product collections

Discount Ninja needs metadata about the products in your collections to evaluate discount eligibility and calculate discounted prices.

To optimize for performance, please ensure all data tags are available in the HTML of your collection products. This requires the setup of Dynamic Pricing as documented here. You can request support from our team in the app. Go to Settings > Dynamic Pricing > Installation to request support.

This is especially important if collections contain a large set of products or if your collection pages use an "infinity scroll" feature.

Tip 3: Limit the number of promotions / offers

Discount Ninja is designed to handle and combine multiple promotions and offers. For best performance, it is advised to limit the number of active promotions to the minimum you require.

Adding a large set (100+ offers) may result in:

  • A delay after saving settings in the app during which promotions are processed and saved to our cache for performance optimization purposes. This may cause significant delays when testing. If offers reference a large number of products or collections this may further increase delays.

  • Minor delays in applying promotions to your products on your shop

Did this answer your question?