Sunday, 13. August 2006, 07:25:06
Performance Problem.
I don´t know why, but I have a lot of problems with performance in same widgets that I write, and I don´t know why it happends, and what I can do to solve it.Two widgets, in special, have this problem: this http://widgets.opera.com/widget/4687 , and this http://widgets.opera.com/widget/4937 .
What I can do to improve the speed of it ?
PS: I have a third widget (http://widgets.opera.com/widget/4748) with this problem too, but It´s obvious why it happen.
Monday, 14. August 2006, 01:01:44
Tried the HTML editor thing, didn't notice anything really, the menu just was a bit slow..
Anyway, looking at the source code for it.. there are some things that I've read before about JS performance and here's what could be causing some in the HTML editor at least:
document.getElementById: when often using an element in a document, it's better performance-wise to save a reference of it to a variable instead of calling document.getElementById every time. For example those key events should probably use a variable.
other than that, you have rather large arrays there. They could cause some slow down but it's probably unavoidable.
Anyway, looking at the source code for it.. there are some things that I've read before about JS performance and here's what could be causing some in the HTML editor at least:
document.getElementById: when often using an element in a document, it's better performance-wise to save a reference of it to a variable instead of calling document.getElementById every time. For example those key events should probably use a variable.
other than that, you have rather large arrays there. They could cause some slow down but it's probably unavoidable.
Saturday, 19. August 2006, 05:03:29 (edited)
Okay... I've run into one myself now.
This problem, however, is odd.
As I have these tabs in my config page and nothing else is going on except a function gets called once a second but does nothing because I'm checking if the config page is open... then if you try to click on a tab to open it... Nothing happens. Only doubleclicking will open the tabs.
The weird part is that there's nothing that should be slowing them down. The single function has been called once a second as long as my widget has existed and the config page never showed slowdown or such until now...
It would seem that much JS = slowdown. Even if your code doesn't do anything, things like click events stop working properly.
I'm currently trying to optimize my code in hopes of fixing it. I'll post results, provided there's anything to say.
note: the problem isn't in the tab code, as even the simple widget flip button doesn't do anything unless you doubleclick it.
This problem, however, is odd.
As I have these tabs in my config page and nothing else is going on except a function gets called once a second but does nothing because I'm checking if the config page is open... then if you try to click on a tab to open it... Nothing happens. Only doubleclicking will open the tabs.
The weird part is that there's nothing that should be slowing them down. The single function has been called once a second as long as my widget has existed and the config page never showed slowdown or such until now...
It would seem that much JS = slowdown. Even if your code doesn't do anything, things like click events stop working properly.
I'm currently trying to optimize my code in hopes of fixing it. I'll post results, provided there's anything to say.
note: the problem isn't in the tab code, as even the simple widget flip button doesn't do anything unless you doubleclick it.
Saturday, 19. August 2006, 05:21:33
Okay, I did some research and this is what I found out:
The code I was using is the code from my World Clocks widget.
I commented out everything except the JS block which is used to flip the widget and show the config page. The only active thing left was the HTML code, so the JS code couldn't be eating up any memory, CPU or anything.
Clicking on the flip button: nothing
Doubleclicking on the flip button: flip
Then for a test, I opened the widget .html file in the browser normally
Clicking on the flip button: flip
Odd. It would seem there's some kind of a bottleneck in widget performance. There was absolutely nothing except the sheer size of the JS code which slowed down the widget. Even commented out, it still loomed over it... Kind of a problem if you want to code a widget with lots of features.
The code I was using is the code from my World Clocks widget.
I commented out everything except the JS block which is used to flip the widget and show the config page. The only active thing left was the HTML code, so the JS code couldn't be eating up any memory, CPU or anything.
Clicking on the flip button: nothing
Doubleclicking on the flip button: flip
Then for a test, I opened the widget .html file in the browser normally
Clicking on the flip button: flip
Odd. It would seem there's some kind of a bottleneck in widget performance. There was absolutely nothing except the sheer size of the JS code which slowed down the widget. Even commented out, it still loomed over it... Kind of a problem if you want to code a widget with lots of features.
Saturday, 19. August 2006, 09:47:06
yes.. apperently JS slows widgets down, but I see no reason why it should be so..
Could be some sort of bug in Opera
Could be some sort of bug in Opera
Forums » Opera Community » General Opera topics » Opera Widgets
