blueswen / mkdocs-glightbox

A MkDocs plugin supports image lightbox (zoom effect) with GLightbox.
https://blueswen.github.io/mkdocs-glightbox/
MIT License
115 stars 14 forks source link

glightbox exponentially slower with increase of the number of images #44

Open PlasmaHH opened 3 weeks ago

PlasmaHH commented 3 weeks ago

I have a page with ~50 images and it takes forever to build. Just take some existing project and copy an image directive a lot of times to see for yourself.

I have stopped it in the debugger and it hangs in the regex sub of plugin.py around line 139 where it tries to do all the replacements in one go. I guess the look back/ahead of the regex there degenerates when it sees that many image tags.

maybe using the find_all in regexes and then looping over the matches works better?

PS: I think the re.compile in the function would benefit from being on the class level to only be ever executed once