Splunk Dev

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

joao_amorim
Communicator

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

jeffland
SplunkTrust
SplunkTrust

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.

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...