Load visualization plugin on demand

urbido

Member
Hi, I have custom map visualization plugin (openstreetmap, based on googlemaps plugin). Working just with views/openstreetmap/tmpl/default/default.php and openstreetmap.js in the way default.php load all params, render html template and call main function from JS file. But since the map is getting too complicated and takes too long to load and it is on intro page, I want to load whole plugin with all dependencies on button click for example. I have tried to work with PlgContentFabrik, with FabrikViewOpenstreetmap, but still no result. Any tips how to load plugin based on some action?

Thanks
Stepan
 
Last edited:
Have you looked at the code for the "deferred loading" in the main Google map viz? I added that specifically to work around large, complex maps that take a while to load, so setting "deferred load" waits until the page is loaded, then fires off an AJAX refresh.

-- hugh
 
I don't think that this is my solution. In default.php I am adding to $document probably 10 JS libraries, 7MB in total. And I don't want to load any of it until button is clicked
Stepan
 
Hmmm, that's harder to do. You might be able to do it by constructing your own requirejs shim for it, although that gets a bit complex, or just doing a simple require() on an array of JS file.

If you aren't familiar with requirejs, it's an AMD loader, which Fabrik uses for handling async loading of all our JS. The way we use it, we create dependencies and a complex config as we build the page to be loaded. A relies on B relies on C, etc. But you can just do ...

Code:
require(['/path/to/your.js', '/path/to/another.js']);

If your included libs don't have dependencies, ie. none of them rely on another one being included first, then just doing that require() after a click on your button should do it.

So I think the answer to your original question is no, Fabrik doesn't support on-demand / lazy loading of plugins, but you can roll your own code to do it.

-- hugh
 
What about an "identical" hidden menu item.
So your intro page is showing some content + a link (button) to the hidden menu item which then will show all of the intro page + the map
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top