table-of-contents-plus icon indicating copy to clipboard operation
table-of-contents-plus copied to clipboard

JS & CSS included on all page loads, whether needed or not

Open wadetregaskis opened this issue 1 year ago • 4 comments

e.g. on feed pages, where the ToC is never rendered.

Specifically, front.min.js & screen.min.css.

It is somewhat possible to manually block these using plug-ins like Asset CleanUp, but it'd be nice if that weren't necessary (TOC+ is otherwise such a nice, svelte plug-in - it's a shame to have to install a behemoth like Asset CleanUp in order to use it).

wadetregaskis avatar Jan 01 '24 03:01 wadetregaskis

Like most others, this plugin uses wp_enqueue_scripts to load js and css files at the appropriate viewports, that is usually in browser, for a normal web page. This shouldn't be outputting to feeds. I can confirm from testing that it is operating correctly for me (no js/css files in feeds).

zedzedzed avatar Feb 20 '24 02:02 zedzedzed

To be clear, by 'feed pages' I mean things like the home page (assuming it's set to list recent posts), search results, etc. When only excerpts are shown, the ToC cannot be presented because WordPress doesn't allow anything but plain text in excerpts (well, other than the feature image, if set).

I do not mean the RSS feeds.

wadetregaskis avatar Feb 20 '24 03:02 wadetregaskis

Have attempted to prevent the CSS and JS files from being added. At the moment, it respects your TOC settings so it won't output to the homepage if you've disabled that or to a disabled post type for auto insertion. A limitation is that it will still output to an eligible page if there are not enough headings.

zedzedzed avatar Feb 21 '24 01:02 zedzedzed

@zedzedzed The front.min.js file is being inserted regardless of deselection of the options in the plugin settings. Even wp_dequeue_script('toc-front'); is not working.

I had to roll back to version 2311 to fix this.

dhananjaygbhardwaj avatar May 08 '24 08:05 dhananjaygbhardwaj