When I click on Insert/Edit Link or Image, it's take time (or long time) to display the dialog?
Why does it take so long time to display? Is it need to download from the server? Can we make it display more faster?
Seeing as how it's automatically parsing the image or video, I'm assuming the dialogue is just grabbing the necessary code to immediately do so. Again, these are assumptions as I don't have my XF up to test this theory.
I wouldn't make any changes to your code until the theory has been tested
Try it on a local installation with debug enabled in case you screw some things up. Then, if you manage to speed it up, let us know!