Does this work with AJAX page load?

Due to how AJAX requests are executed by server and browser, we can not ensure that all elements will work correctly whenever a page is loaded via AJAX.

The one big drawback of using AJAX to load pages, is that all scripts of the page to be loaded are not properly initialized by an AJAX call. That is not a bug of this plugin or specific to this plugin only, but related to EVERY script that is used on a page that is loaded via AJAX, no matter what plugin those scripts are coming from.

As such, using an AJAX load for pages with any content dependent upon JS routines will fail on those pages, until the page is properly loaded/refreshed the normal way, which is why elements work after you refreshed/reloaded the page. The reason for that lies in the official W3C specification for XMLHttpRequest (AJAX) requests, which states:

“Scripts in the resulting document tree will not be executed, resources referenced will not be loaded and no associated XSLT will be applied.”

Therefore, elements coming from this plugin that rely on JS routines will most likely not work on pages that are loaded with AJAX.

But why are any theme related features not affected by the same limitation?

Your theme is the part that triggers and executes the AJAX call, so your theme, unlike a plugin, knows exactly when such an AJAX call occurred and can simply process what is commonly known as “callbacks”, allowing the theme to either re-load missing files and/or initialize any JS routines again. But plugins don’t have that option, as plugins simply don’t know when such an AJAX call happened, since there is no communication between the theme and/or any of the plugins.


Tekanewa has written 35 articles

Hi there, I am the Lead Developer here at Tekanewa Scripts by Kraut Coding; well, to be honest, I'm also the only developer. I love to create something beautiful and useful for Websites and here I write about how to use them. :)