Skip to main content

Installing Juicer on a Magento website or other RequireJS system

How to load Juicer's legacy embed under RequireJS / AMD systems like Magento. Feeds 2.0's single-line embed needs no AMD wrapper.

Written by Mario T.

⚠️ Legacy embed only. This article applies to Juicer's legacy 3-piece embed (jQuery + embed.js + embed.css), which uses AMD/RequireJS-incompatible global definitions.

If you're on the newer Feeds 2.0 single-line embed (embed-code.js), this configuration is not needed — the Feeds 2.0 script is a vanilla script with no RequireJS conflicts. Embed it normally in your Magento template.

Overview

Some platforms — Magento 2 most notably — bundle RequireJS (an AMD module loader) and intercept inline <script> tags. The legacy Juicer embed defines Juicer as a global and won't initialize correctly under AMD unless it's loaded through RequireJS.

Implementation guide

  1. See our requirejs-example repo on GitHub for a working setup. The repo is small and self-contained — clone it and adapt to your stack.

  2. For Magento 2, add Juicer to your theme's requirejs-config.js using the snippet below, then load the module from your .phtml template.

  3. For other AMD systems, the same pattern applies — register Juicer as a named module and depend on it from the page script.

Code example

Add this to your theme's requirejs-config.js:

var config = {
paths: {
'juicer': 'https://assets.juicer.io/embed'
},
shim: {
'juicer': {
exports: 'Juicer'
}
}
};

Then in your .phtml template, request the module and place the Juicer feed element:

<ul class="juicer-feed" data-feed-id="YOUR-FEED-SLUG"></ul>
<script type="text/javascript">
require(['juicer'], function () {
new Juicer.Widget({ feedId: 'YOUR-FEED-SLUG' });
});
</script>

Replace YOUR-FEED-SLUG with your feed's slug (the same one in your Embed code).

If the feed still doesn't render under RequireJS, send us the Magento version, the page URL, and the contents of your requirejs-config.js through contact us. We can also help you move from the legacy embed to the Feeds 2.0 single-line embed, which sidesteps RequireJS entirely.

Did this answer your question?