WordPress.org

Ready to get started?Download WordPress

Forums

Progress Bar
[resolved] Can I block CSS from loading (9 posts)

  1. Preeminent
    Member
    Posted 1 year ago #

    I'm hoping to cut down on extra requests on page load. Is there a good way to stop calling the extra css file for this plugin, and just add the css to my default site styles file?

    I'm also seeing a javascript file being called. Is that for the quick animation? Can I stop that as well?

    Thanks!

    http://wordpress.org/extend/plugins/progress-bar/

  2. Chris Reynolds
    Member
    Plugin Author

    Posted 1 year ago #

    Yep. You'd use wp_deregister_style and wp_deregister_script, respectively. The scripts and styles are hooked into init so you should be able to hook into anything that fires after that in a function like this:

    function dont_load_progress_bar_stuff() {
    wp_deregister_style( 'wppb_css' );
    wp_deregister_script( 'wppb_animate' );
    }
    add_action( 'init', 'dont_load_progress_bar_stuff' );

    If hooking it into init doesn't work, you could try later...maybe after_setup_theme if you're doing this in a theme.

  3. Chris Reynolds
    Member
    Plugin Author

    Posted 1 year ago #

  4. Preeminent
    Member
    Posted 1 year ago #

    Awesome! Ok, so the "dont_load_progress_bar_stuff" would be my own hook from my theme, right? Just find a hook from my theme?

    Then, as long as I have the css, and don't want the animated part, the progress bars should work fine without the javascript, right?

  5. Chris Reynolds
    Member
    Plugin Author

    Posted 1 year ago #

    that would be your function if you wanted to do a separate function. Alternately, if your theme is doing something like what twentyten/twentyeleven does with the twentyten_setup_theme function with all the setup stuff, you could probably throw it in there.

    And yeah, the only thing the javascript does is the pretty animation. I had considered eliminating it entirely from the plugin when I first wrote it but decided to keep it in because it's not that big but it's purely cosmetic. The only other thing is the jquery loading. Probably your theme or a plugin is loading jquery somewhere, so it's not going to hurt anything, but I wouldn't want to deregister jquery because that could prevent other plugins from being able to use jquery.

  6. Preeminent
    Member
    Posted 1 year ago #

    Ok, it's working as far as stopping those from loading, but now the progress bars aren't showing. It's actually just showing "50%" where the bar should be for example. So I will see if I can find something other than init to use.

  7. Chris Reynolds
    Member
    Plugin Author

    Posted 1 year ago #

    That's actually probably right because you're deregistering all the CSS and CSS is pretty much all the plugin is. Just copy the CSS from the stylesheet in the plugin into your theme's style.css and you'll be set.

  8. Preeminent
    Member
    Posted 1 year ago #

    Ok, got it! Sorry, Chrome has been doing weird things today, and not accepting my css changes right away. I did have to use init. Again, thanks a ton for your quick help on this!!

  9. Chris Reynolds
    Member
    Plugin Author

    Posted 1 year ago #

    NP :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic