Which of the following would be the fastest implementation for an HTML Analyzer

I’m creating a simply WYSIWYG editor, and what I want to do before / after uploading the HTML is convert it to a cleaner version that would look more like handwritten code, as well has make different content look more uniform regardless of the browser it was written in. Because of how there are minor bugs as to how the browser being used might render certain things, I want to allow the user to get a preview before submission.

What I’m faced with is how to best implement that clean up process, and is fast. There are three ways I can think of.

  1. Use Python (what I’m using in the back end) to clean it, using AJAX to pass back and forth
  2. Use JS
  3. Skip using execCommand and make it to where no clean up is necessary.

Pros and cons that I’m thinking of:

  1. Python seems like the faster option, but I didn’t find anything nearly as powerful, library-wise, which can process the DOM like JS. Hence there would be no things like .innerHTML or getElementById (I didn’t do a very involved search, so I may have missed something more powerful)

  2. JavaScript has all the DOM access that I’m used to, but I’m not sure if this would end up being extremely slow with larger segments of code to process.

  3. Creating my system would mean no cleanup, but then again, that’s only if done well. Things can get pretty messy, very fast, which is why I didn’t go this route to start. I’d essentially have to climb up and down the DOM every command to determine if say, there was a bold tag, and then modify it appropriately, by moving the beginning / end to the right spot, and possibly creating more or less tags, based on what is already around it.

I’m leaning towards option 2 due to simplicity, but if that’s going to be slow, and it would be better to use Python in the back, though not as easy, I’d be for it. I just don’t want to freeze the browser or make the user wait 10 seconds for something to process.

Note that I am using native JS, no libraries.

Thanks for the input.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.