• Hi folks

    I’ve been investigating this problem since some time now and could not find a solution.

    The problem: code bloat. All WordPress HTML files for a specific Web site contain 1300+ lines of unneeded WP media code, regardless if logged in or out as admin. If these were at least just external JS files, I could exclude them but no, the code is inline. Following is the list of the inline WP Javascript files:

    <script type=”text/html” id=”tmpl-media-frame”>
    <script type=”text/html” id=”tmpl-media-modal”>
    <script type=”text/html” id=”tmpl-uploader-window”>
    <script type=”text/html” id=”tmpl-uploader-editor”>
    <script type=”text/html” id=”tmpl-uploader-inline”>
    <script type=”text/html” id=”tmpl-media-library-view-switcher”>
    <script type=”text/html” id=”tmpl-uploader-status”>
    <script type=”text/html” id=”tmpl-uploader-status-error”>
    <script type=”text/html” id=”tmpl-edit-attachment-frame”>
    <script type=”text/html” id=”tmpl-attachment-details-two-column”>
    <script type=”text/html” id=”tmpl-attachment”>
    <script type=”text/html” id=”tmpl-attachment-details”>
    <script type=”text/html” id=”tmpl-media-selection”>
    <script type=”text/html” id=”tmpl-attachment-display-settings”>
    <script type=”text/html” id=”tmpl-gallery-settings”>
    <script type=”text/html” id=”tmpl-playlist-settings”>
    <script type=”text/html” id=”tmpl-embed-link-settings”>
    <script type=”text/html” id=”tmpl-embed-image-settings”>
    <script type=”text/html” id=”tmpl-image-details”>
    <script type=”text/html” id=”tmpl-image-editor”>
    <script type=”text/html” id=”tmpl-audio-details”>
    <script type=”text/html” id=”tmpl-video-details”>
    <script type=”text/html” id=”tmpl-editor-gallery”>
    <script type=”text/html” id=”tmpl-crop-content”>
    <script type=”text/html” id=”tmpl-site-icon-preview”>

    System environment: lastest WP with Elementor, Woocommerce, Kadence Theme, and Modern Events Calendar.

    It seems that WordPress itself is the culprit here.

Viewing 4 replies - 1 through 4 (of 4 total)
  • These scripts are only normally enqueued in the backend / admin.

    You are seeing this in the from end because something, a theme or plugin is enqueuing them in the front end.

    It isn’t a default WordPress behaviour, so you will need to identify the theme or plugin that is doing this.

    One way is via a process of elimination, set default theme turn off all plugins and turn on one at a time ( and then view as a non logged in user e.g. in incognito mode ), or you can scan the code for any plugin or theme that is calling wp_enqueue_media() https://developer.www.ads-software.com/reference/functions/wp_enqueue_media/

    • This reply was modified 3 years, 5 months ago by Alan Fuller.
    • This reply was modified 3 years, 5 months ago by Alan Fuller.
    Thread Starter ppwebox

    (@ppwebox)

    Thanks for your input, appreciated!

    Problem is that most of the plugins (but no themes), including Woocommerce, use wp_enqueue_media in one or more of their PHP scripts.

    It seems that WordPress itself is the culprit here.

    Problem is that most of the plugins (but no themes), including Woocommerce, use wp_enqueue_media in one or more of their PHP scripts.

    If they are enqueuing in the front end when it is not needed then they are ‘doing it wrong’

    So is this something that WordPress needs to fix or WooCommerce and others? Just wondering what your thought process is.

    • This reply was modified 3 years, 5 months ago by Alan Fuller.
    Thread Starter ppwebox

    (@ppwebox)

    Well, coming from old-school website development building sites from hand without any tools besides a text editor, it’s the lack of code discipline that bothers me.

    I think the WordPress CMS itself is quite OK, aside from its still obvious history of having been developed as a blog management system. But it requires third-party plugins and to a lesser degree themes to match the requirements of today’s commercial web development. The coding restrictions set by WordPress for third-party developers appear to be very liberal. A majority of WP plugin devs are from emerging countries where the focus is on selling & cashing-in as quick as possible, and not on delivering reliable and streamlined products. Hence the many bug problems with even mature WP plugins. And then there is the code bloat problem leading to large Web files and slow performance.

    There’s no redundancy control, no efficient coding framework when it comes to HTML/CSS/JS output on a WP system. On a simple HTML file with some text and a photo I can count 36 style sheets, and 75 scripts, which is astonishing. The more Web code the more electrical energy is wasted through routers, servers, browsers, and the user device. Multiplied by millions of users on a daily basis the waste is significant. And most plugins come with more features with each new version, leading to even larger Web output files, more database queries, and potentially more stability issues.

    WP today is like a open-house kitchen where too many freelance cooks spoil the menu. The only way to solve the stability/performance issue would be for WP to come with a full-blown built-in page builder (optionally a pro version for a license fee), I guess. Or a close cooperation with a handful of selected page builder companies to ensure better code control. It does not help that WP was initially conceptualized as a plain blog management tool, which is in very strong contrast to what it’s mostly used today – eCommerce and dynamic web sites requiring a multitude of front-and back-end features.

    On the other hand, WP is open-source hence free, which of course is great and therefor a big thanks to all participating developers for their time and efforts.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WordPress bloat: 1300+ lines of redundant code in HTML files’ is closed to new replies.