You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, I use a theme in my WordPress sites that uses the function wp_get_attachment_image for rendering image tags. This function takes the attachment ID and renders its HTML tag (<img>).
I have a huge database with +4,000,000 rows in my wp_posts table. The function wp_attachment_get_image will take 0.1 to 0.2 seconds for rendering SVGs, while the Jpegs and PNGs take only 0.0001 seconds for rending the same tag with the same functions.
Turning on the PHP slow execution log, I could trace back the cause of the slowness. It is the function simplexml_load_file. I added below the file that is using it:
So, to summarize, those are the times I have when the Safe SVG is turned on:
And those are the times I have with it off:
Your plugin is by far the most used by my company. I really would appreciate it if you help me to solve the issue.
Steps to Reproduce
For tracking the timing I used the plugin Query Monitor, together with the following hooks around the function wp_get_attachment_image for tracking the execution time:
Another thing you could do in order to reproduce the error would be just to render 30 to 40 SVGs on a page. It would slow the page down, consuming 4 to 10 seconds for rendering the page.
Screenshots, screen recording, code snippet
No response
Environment information
PHP 8.2
WordPress 6.3
Safe SVG 2.2.0
WordPress information
No response
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
dkotter
changed the title
Funciotion used by Save SVG is slowing down wordpress pages
Function used by Save SVG is slowing down wordpress pages
Sep 12, 2023
Describe the bug
Currently, I use a theme in my WordPress sites that uses the function wp_get_attachment_image for rendering image tags. This function takes the attachment ID and renders its HTML tag (
<img>
).I have a huge database with +4,000,000 rows in my wp_posts table. The function
wp_attachment_get_image
will take 0.1 to 0.2 seconds for rendering SVGs, while the Jpegs and PNGs take only 0.0001 seconds for rending the same tag with the same functions.Turning on the PHP slow execution log, I could trace back the cause of the slowness. It is the function simplexml_load_file. I added below the file that is using it:
![image](https://private-user-images.githubusercontent.com/22755734/265231798-6fc122f9-a8a9-4336-bb59-7ffdad027edf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwMTU2OTIsIm5iZiI6MTczOTAxNTM5MiwicGF0aCI6Ii8yMjc1NTczNC8yNjUyMzE3OTgtNmZjMTIyZjktYThhOS00MzM2LWJiNTktN2ZmZGFkMDI3ZWRmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDExNDk1MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTZhYTJlYzA3YWJkN2VjM2FjOWM3N2ZiYzQ0YTI2NGQ1NTFlYjkzNWRhYWJkNzFkM2ZhZDIxNmFhMTIzYjRmNTYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.yvZhDQ67lHGxRON0BA9eC0U8LGK7EixQfZzB-Fyg70M)
So, to summarize, those are the times I have when the Safe SVG is turned on:
![image](https://private-user-images.githubusercontent.com/22755734/265231860-e911d2d9-0269-4981-ba93-48ea9792d311.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwMTU2OTIsIm5iZiI6MTczOTAxNTM5MiwicGF0aCI6Ii8yMjc1NTczNC8yNjUyMzE4NjAtZTkxMWQyZDktMDI2OS00OTgxLWJhOTMtNDhlYTk3OTJkMzExLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDExNDk1MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM4ZWY0ZjEwNmIyNGY0NjU2NjY4M2M3YjQwNTllNTFhZDQ5OTZlZTQzMDYwZWUxNjhjMDg0ZjU0NWYzZTkxMmMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.N6meiMLJ3ldRWwhJZDysWu7xSpZD7Vi48iSTgyU_KE8)
And those are the times I have with it off:
![image](https://private-user-images.githubusercontent.com/22755734/265231838-be12e630-f236-4e6a-ac49-98c2febcdf54.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwMTU2OTIsIm5iZiI6MTczOTAxNTM5MiwicGF0aCI6Ii8yMjc1NTczNC8yNjUyMzE4MzgtYmUxMmU2MzAtZjIzNi00ZTZhLWFjNDktOThjMmZlYmNkZjU0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDExNDk1MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBmYjBlYTVmOWU3YTJmNDdhYmNkMjFhYjQ3MTAzZDIxNDVlY2Y4YjlmNGM2OTBiNzMxZjc2NDVlZjQ0ZmUyNDcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.wEQ0v_13ckBi-oksyUYZjIWjXa491ZXvMPp4wmmP4Ao)
Your plugin is by far the most used by my company. I really would appreciate it if you help me to solve the issue.
Steps to Reproduce
For tracking the timing I used the plugin Query Monitor, together with the following hooks around the function wp_get_attachment_image for tracking the execution time:
Another thing you could do in order to reproduce the error would be just to render 30 to 40 SVGs on a page. It would slow the page down, consuming 4 to 10 seconds for rendering the page.
Screenshots, screen recording, code snippet
No response
Environment information
PHP 8.2
WordPress 6.3
Safe SVG 2.2.0
WordPress information
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: