I'm writing messenger for social network. That's how it works:
- Getting dialogs list with API
- Getting info (name, avatar) about users
- Showing that in QWebView.
Here is some code:
void Messenger::loadedMoreDialogs() {
QString javascript;
javascript += "html = \"" + dialogsHtml + "\";";
javascript += "$('#dialogList').append(html);";
javascript += "$('#name').html('" + name + "');";
javascript += "$('#surname').html('" + surname + "');";
javascript += "$('#loading').hide(200);";
for (int i = 0; i < usersInfo.count; i++) {
javascript += QString("$('#owner") + QString::number(usersInfo.list[i].id) + QString("').html('") + usersInfo.list[i].name + QString(" ") + usersInfo.list[i].surname + QString("');");
javascript += QString("$('#avatar_dialog") + QString::number(usersInfo.list[i].id) + QString("').prop('src', '") + usersInfo.list[i].avatar_50 + QString("');");
}
javascript += "$('img[chat=\"1\"]').replaceWith($('<div class=\"confAvatar\"> </div>'));";
browser->page()->mainFrame()->evaluateJavaScript(javascript);
}
So, when i'm executing JS (in last line of function), browser become frozen on ~1 second.
Ok guys, problem solved. It was JQuery. I just removed it. No lags now.