0

I am working on a firefox extension that gets the html content from the current tab in the browser. Majority of the processing takes place in popup.js file which is embedded in the popup UI that is displayed on clicking the toolbar icon for the extension. Due to this, the performance of the extension suffers and occasionally I see a spinning wheel while capturing. Is there a way I could move this processing to the background? I am loading a script using the loadFrameScript api when the capture button is clicked.

Is there any such thing as background page in Firefox extensions like in chrome and Safari? If no, please suggest a way to optimize this.

Vivek
  • 680
  • 1
  • 12
  • 24
  • What sort of processing is done? You say you take the entire HTML content, possibly you're grabbing too much? Usually only a small subset of that content is actually needed. – Ashley Strout May 15 '12 at 16:56
  • Yes, I am grabbing the entire html content and parsing the data and removing stuff that I don't need. – Vivek May 15 '12 at 17:00
  • Again, I don't know what you're doing, but is it possible that rather than grabbing _everything_, you can use functions like `getElementsByTagName`? – Ashley Strout May 15 '12 at 17:18
  • @David I have to capture the entire html page as is with style and everything, so getElementsByTagName is not an option. :( – Vivek May 15 '12 at 17:42
  • I'm just making up options here. It's up to you to determine the adequate way (if any) to limit the data necessary to process. `getElementsByTagName` was just one option, there are others. I can better advise you if I know what you're doing with the captured HTML. – Ashley Strout May 15 '12 at 17:43
  • Thanks @David. I am passing the root element of the document (window.document) to a method in which I am iterating through each of the nodes and then extracting the innerHTML content from the node. Along with this, I am computing the style of each node using the getComputedStyle() api. I am then constructing the html data from the data using this data. The iterating of the node is using a while loop. – Vivek May 15 '12 at 18:03
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/11273/discussion-between-quad-damage-and-david) – Vivek May 15 '12 at 18:05

1 Answers1

0

Use a Web Worker, if there is some reason why you can't then can you explain that?

erikvold
  • 15,988
  • 11
  • 54
  • 98