• Resolved cag8f

    (@cag8f)


    Hello. I have installed the plugin and used it to display/style SVG images on one of my pages (https://kabultec.org/news-and-press/). I have not added any SVG files to my home page. But your plugin still loads two files onto my home page:

    svgs-attachment.css

    Some image with the target:

    data:image/svg+xml;utf8,<svg xmlns='https://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'><path d='M18.9 4.3c0.6 0 1.1 0.5 1.1 1.1v13.6c0 0.6-0.5 1.1-1.1 1.1h-10.7c-0.6 0-1.1-0.5-1.1-1.1v-3.2h-6.1c-0.6 0-1.1-0.5-1.1-1.1v-7.5c0-0.6 0.3-1.4 0.8-1.8l4.6-4.6c0.4-0.4 1.2-0.8 1.8-0.8h4.6c0.6 0 1.1 0.5 1.1 1.1v3.7c0.4-0.3 1-0.4 1.4-0.4h4.6zM12.9 6.7l-3.3 3.3h3.3v-3.3zM5.7 2.4l-3.3 3.3h3.3v-3.3zM7.9 9.6l3.5-3.5v-4.6h-4.3v4.6c0 0.6-0.5 1.1-1.1 1.1h-4.6v7.1h5.7v-2.9c0-0.6 0.3-1.4 0.8-1.8zM18.6 18.6v-12.9h-4.3v4.6c0 0.6-0.5 1.1-1.1 1.1h-4.6v7.1h10z' fill='rgba(240,245,250,.6)'/></svg>

    Is it necessary for the plugin to load these files on the home page? If not, how can I prevent it from occurring?

    Thanks.

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Benbodhi

    (@benbodhi)

    Hi there,
    You probably don’t need that CSS file in your case.
    Simply dequeue it in your functions file or snippets plugin, or write a simple plugin to handle that. Here’s the code:

    /**
     * Dequeue the stylesheet.
     *
     * Hooked to the wp_print_styles action, with a late priority (100),
     * so that it is after the style was enqueued.
     */
    function bodhi_dequeue_svgs_css() {
       wp_dequeue_style( 'bodhi-svgs-attachment' );
    }
    add_action( 'wp_print_styles', 'bodhi_dequeue_svgs_css', 100 );
    
    Thread Starter cag8f

    (@cag8f)

    OK thanks very much, that succeeded in preventing the stylesheet from loading. But what about the SVG image that it loads–what is that? Is it necessary? Can I prevent it from loading as well?

    Plugin Author Benbodhi

    (@benbodhi)

    My pleasure,
    I don’t think my plugin loads that…
    I can’t see it in your page, where is it exactly?

    It might be an icon from a password manager? For example, I use dashlane for passwords and it puts a little icon in fields where it can do something. It’s not actually in the page though.

    Thread Starter cag8f

    (@cag8f)

    >> I don’t think my plugin loads that…
    >> I can’t see it in your page, where is it exactly?

    Whoops, my mistake–it is not from your plugin. It is an SVG image, but loaded by something else–something that appears in the WordPress admin bar. So no need to worry about that.

    But lastly, on my *dev* site home page, for some reason, your plugin is loading a JS file:

    /js/min/svgs-inline-min.js?ver=1.0.0

    But this is occurring only on my private dev site home page, and not my live site home page. Any ideas why there would be a discrepancy there? The two home pages are identical.

    Plugin Author Benbodhi

    (@benbodhi)

    That is the JS to find SVG files in the DOM and then render them inline… if you have chosen to do so.
    So it is necessary for inlining SVG files.
    You can control whether it is in the header or footer from the plugin settings, but it will definitely be enqueued somewhere. UNLESS, you have deactivated the advanced mode of my plugin. It’s only enqueued when the advanced mode is active, allowing you to inline SVG files. But if you just use SVG like images and don’t need them inline, you can switch it off completely.

    I dare say that you have one site in advanced mode and the other not.

    Thread Starter cag8f

    (@cag8f)

    >> I dare say that you have one site in advanced mode and the other not.

    OK I checked, and that is indeed the case. I disabled Advanced Mode on the dev site, and the JS file was no longer loaded.

    Thanks for your help! We can consider this resolved.

    Thread Starter cag8f

    (@cag8f)

    Actually, I have one last question. The PHP code you gave me ensures the CSS file is not loaded on any pages. But that also includes the one page on my site that *does* indeed display (and style) SVG images. So svgs-attachment.css is not loaded on this page. Will that be an issue? As a test, I loaded the page, and all SVG images display as expected.

    Plugin Author Benbodhi

    (@benbodhi)

    Hey,

    SVG files will display fine and can be used like any other image without advanced mode.
    The only reason you want advanced mode on is to render SVG files inline, which is a pretty edge case really. So if you just want to use SVG files like any other image, you can leave it off and it doesn’t matter if the CSS isn’t there. That CSS is tiny, and just covers when an SVG is used as a featured image.

    Thread Starter cag8f

    (@cag8f)

    OK thanks. We can consider this resolved.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to prevent SVG Support plugin from loading unnecessary files?’ is closed to new replies.