• I guess this is a 5.x issue, as I’ve been slow to move some larger sites.

    I see a TON of files being included from the wp-includes/js/dist directory (33 to be exact). I only noticed this when benchmarking the site and these were flagged for not being minified, having a query string, not being deferred, etc.

    What is triggering this? I have the classic editor plugin installed and enabled, BTW.

    Here’s a list of files:

    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/autop.min.js?ver=2.0.2'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/blob.min.js?ver=2.1.0'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/block-serialization-default-parser.min.js?ver=2.0.3'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/vendor/lodash.min.js?ver=4.17.11'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/vendor/react.min.js?ver=16.6.3'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.6.3'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/escape-html.min.js?ver=1.0.1'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/element.min.js?ver=2.1.8'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/is-shallow-equal.min.js?ver=1.1.4'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/compose.min.js?ver=3.0.0'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/redux-routine.min.js?ver=3.0.3'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/data.min.js?ver=4.2.0'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/dom.min.js?ver=2.0.8'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/hooks.min.js?ver=2.0.4'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/html-entities.min.js?ver=2.0.4'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/i18n.min.js?ver=3.1.0'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/shortcode.min.js?ver=2.0.2'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/blocks.min.js?ver=6.0.5'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/url.min.js?ver=2.3.3'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/api-fetch.min.js?ver=2.2.7'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/vendor/moment.min.js?ver=2.22.2'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/keycodes.min.js?ver=2.0.5'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/rich-text.min.js?ver=3.0.4'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/components.min.js?ver=7.0.5'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/core-data.min.js?ver=2.0.16'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/date.min.js?ver=3.0.1'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/deprecated.min.js?ver=2.0.4'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/notices.min.js?ver=1.1.2'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/nux.min.js?ver=3.0.6'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/token-list.min.js?ver=1.1.0'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/viewport.min.js?ver=2.1.0'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/wordcount.min.js?ver=2.0.3'></script>
    <script type='text/javascript' src='https://example.com/wp-includes/js/dist/editor.min.js?ver=9.0.7'></script>
Viewing 8 replies - 1 through 8 (of 8 total)
  • Maybe you can install the WP Healthcheck Plugin and go through debugging. This will enable you to safely disable all your plugins and revert to a default theme which will help you narrow down where the issue lies. It could be a theme issue, single plugin, or combination of multiple plugins.

    Thread Starter sporkme

    (@sporkme)

    All of these files are being served out of “wp-includes/js/dist”, which is not a plugin directory…

    You’re right but WordPress has a bunch of javascript libraries included in the install which themes and plugins can use if they decide to. By default, none of these scripts are included in the output of the front-end of your website unless specifically asked to by a theme or plugin.

    For example, if I want to use jQuery in my plugin I can enqueue it and it will pull it from the WordPress wp-includes folder so 1) it doesn’t need to go to an outside source to load jQuery and 2) it’s known stable.

    wp_enqueue_script( 'jquery' ); will add the WordPress included jquery script to your header like you’ve noted above.

    This means that if a plugin or theme is enqueueing a bunch of scripts for one reason or another this would show up. Here’s a list of WordPress included scripts that are available for theme and plugin authors to use.

    The fore-mentioned plugin will help you narrow down what the cause is.

    Thread Starter sporkme

    (@sporkme)

    The plot thickens… no such thing on the staging copy of the site. This is going to be a fun one.

    Thanks for that reference, I don’t remember seeing such a comprehensive list of available built-in stuff before. I wish the “handle” name aligned with the filename…

    Moderator Dion Hulse

    (@dd32)

    Meta Developer

    As a slightly-educated guess – You may find a plugins JS file has flagged editor as a dependancy for some block-editor tie-in it has, which then makes WordPress load all of the block editor JS dependancies even though they’re not being used on the page (But WordPress doesn’t know that, as the plugin said it needed it)

    (edit: The file immediately following that editor.min.js enqueue is probably the file which has them listed as a dependancy)

    • This reply was modified 5 years, 10 months ago by Dion Hulse.
    Thread Starter sporkme

    (@sporkme)

    Found it! Commercial plugin that was not allowed to update on the staging site. On the public site it did update, and it indeed was doing something to trigger the loading of all those includes.

    Is any block editor-based page/post always going to suck in all those JS files? That seems a little crazy.

    Anyhow, this is the plugin: https://eventcalendarnewsletter.com/the-events-calendar-shortcode/

    Hi @sporkme!

    Author of The Events Calendar Shortcode here, definitely a fun issue for plugins like mine that are adding a block for the new editor. Did our best to reduce the number of files (ie. everything is compiled down to one JavaScript file in our plugin for distribution), but it does depend on and include the now standard 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' scripts which in turn can include others.

    That said, these scripts are only added using the enqueue_block_editor_assets hook, so they should only be added to the back-end of the site. There may be another plugin on the site perhaps firing this action and including scripts unnecessarily.

    If core Gutenberg/WP editor folks could chime in, but might be worth trying on your site with just The Events Calendar (by Modern Tribe) and this plugin enabled, along with a default theme like Twenty Nineteen, to see if the issue is still present.

    Cheers!

    I think we found the issue. The plugin was using the script and style options to register_block_type when it should have been using editor_script and editor_style. Oddly it didn’t seem to be included on the front-end when using a default theme at least when I was testing, not sure why.

    More detail for anyone who stumbles upon this in the future:

    https://wordpress.org/gutenberg/handbook/designers-developers/developers/tutorials/block-tutorial/applying-styles-with-stylesheets/#enqueueing-editor-only-block-assets

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Too many js files from wp-includes/js/dist’ is closed to new replies.