Building for the Splunk Platform

What's the difference between these two requires: splunkjs/ready! VS splunkjs/mvc/simplexml/ready! ???


Hi guys,

I was wondering, since i searched here and didn't find an answer for this, if any of you can explain me the difference between using require splunkjs/ready! or using require splunkjs/mvc/simplexml/ready! ??

In which case I should use one instead of the other?

Thanks in advance.

0 Karma


The first one, splunkjs/ready!, ensures that all splunkjs libraries are loaded before our code is executed. The second one, splunkjs/mvc/splexml/ready!, ensures that all Simple XML dashboard elements are loaded, i.e. your panels, search managers and visualizations. See here for source and search for "In our JavaScript" to jump to that section.

The idea of both is to ensure your code runs after those two processes are finished, even if one of them takes a while longer, because usually your code won't work or may even create errors if they haven't finished.

Which one you need depends on what you intend to do in your code. If you want to work some behind the scenes magic without touching any of your visualizations, you should be good to go with the first one only. If you want to move around stuff on your dashboard by changing the DOM with jquery or if you want to use a custom visualization using data from a search manager, you should probably use the second one as well.

In my personal experience, using the two ready statements is not strictly necessary, as most code will run fine either way with just the first one (though I've run into problems if that's not there). It's just that sometimes it won't, and to avoid trouble because of not-yet-loaded dashboard elements (also to increase portability: you never know where your apps run, and just because it runs on your machine doesn't mean it runs everywhere), you should use the second one if you operate on dashboard elements as well. Unfortunately, this is just my personal experience and I can't really cite any other reliable sources apart from the one above - but I know I was confused about this at first, too, but I hope I could clear things up a little for you.

Get Updates on the Splunk Community!

Build Scalable Security While Moving to Cloud - Guide From Clayton Homes

 Clayton Homes faced the increased challenge of strengthening their security posture as they went through ...

Mission Control | Explore the latest release of Splunk Mission Control (2.3)

We’re happy to announce the release of Mission Control 2.3 which includes several new and exciting features ...

Cloud Platform | Migrating your Splunk Cloud deployment to Python 3.7

Python 2.7, the last release of Python 2, reached End of Life back on January 1, 2020. As part of our larger ...