zedzedzed / table-of-contents-plus

https://wordpress.org/plugins/table-of-contents-plus/
GNU General Public License v2.0
53 stars 27 forks source link

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

Open wadetregaskis opened 10 months ago

wadetregaskis commented 10 months ago

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).

zedzedzed commented 8 months ago

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).

wadetregaskis commented 8 months ago

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.

zedzedzed commented 8 months ago

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.

dhananjaygbhardwaj commented 6 months ago

@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.