I just started a chrome extension yesterday so I am fairly new, please excuse my noob questions.
I have a popup.js which displays contents in popup.html - So popup.js is simple
popup.js
$(document).ready(function () {
    chrome.tabs.getSelected(null, function (tab) {
        chrome.runtime.sendMessage({
            tab: tab
        }, function (response) {
            document.getElementById("lockDiv").hidden = false;
            document.getElementById("loadingDiv").hidden = true;
        });       
    });
});
It gets the selected tab, sends a message (with tab) to event page which is the following
eventPage.js
chrome.runtime.onMessage.addListener(function (tab) { 
    chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
        setInterval(function () {
           // Do something after 5 seconds          
        }, 5000);
    });   
}); 
Now it works (sort of) but as soon as popup.js runs, there is no delay for 5 seconds before this executes
        document.getElementById("lockDiv").hidden = false;
        document.getElementById("loadingDiv").hidden = true;
The above executes without waiting for the response from eventPage.js
How can I make this to wait for a response and let the operation in evenPage.js to finish before showing executed the above code?
 
    