Instagram Widget doesn’t load on ajax-powered WordPress websites

Customers with ajax-powered WordPress websites have sometimes complained of a plugin loading issue. The gist of the issue is that when you visit a page without the plugin, and then go to the page with the plugin, the plugin doesn’t load until you refresh the page.

Ajax functionality can occasionally cause issues with our plugin’s work. Fortunately, we have a pretty universal solution, that should help you fix them regardless of your website’s theme. might.

First, you need to go to Preferences page and enable the option “Add plugin script to every page”. Next, add the following code to Custom JS field:

var elfsightObserver;

var elfsightInitiator = function(slug, callback) {
    var widgets = document.querySelectorAll('[data-elfsight-' + slug + '-options]'){
        var settings = JSON.parse(decodeURIComponent(widget.getAttribute('data-elfsight-' + slug + '-options')));

        callback(widget, settings);

if (window.MutationObserver && !elfsightObserver) {
    var elfsightObserver = new MutationObserver(function(mutations) {
        mutations.forEach(function(m) {
            if (!m.addedNodes || !m.addedNodes.length) {

                // elfsightInitiator(slug, callback);
                elfsightInitiator('instagram-widget', function(widget, settings) {
                    window.eappsInstagramWidget(widget, settings);

                window.dispatchEvent(new Event('resize'));

    document.addEventListener('DOMContentLoaded', function() {
        elfsightObserver.observe(document.body, {
            childList: true,
            subtree: true

Press Save, and check your plugin again.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us