WordPress.org

Ready to get started?Download WordPress

Forums

MnCombine
[resolved] Is there a way to add other external Non-WP files? (5 posts)

  1. colourstone
    Member
    Posted 1 year ago #

    Hi, thanks for the help in advance.

    Is there a way to add other external CSS, JS, and other files to be combined and compressed? I use some other CSS files with my theme. Also some of the plugins that I am using use JS, images, and CSS from amazon and other sites. Can I combine these to be compresses and minified?

    Thank you,
    Brent

    http://wordpress.org/extend/plugins/mncombine/

  2. mneil
    Member
    Plugin Author

    Posted 1 year ago #

    External scripts cannot currently be combined and are completely ignored by the plugin. I recognize the need sometimes to use CDN's to deliver assets like CSS and JS but there just wasn't enough time for me to thoroughly test it. The plugin scans the WP install directory to allow you to choose which files to include so external scripts aren't found. This differs from other plugins that rely on the scripts handle and source coming from wp_enqueue_script at the time of the request. Eventually I will add support for developers to add in handles that should be combined for external sources.

    You could add these sources in yourself now if you wanted to modify my script. Maybe I can release a hook to allow you to inject this information so you don't have to modify the files and can receive updates? Would that be helpful?

  3. colourstone
    Member
    Posted 1 year ago #

    Thanks for the reply mneil!

    I'm not quite sure what to do with the hooks but if you give me little bit of instruction I'll give it a shot. I use a couple of large core CSS files that deliver CSS to several sites. It makes my updates a lot easier but it would be nice to combine these files with the others.

    I'm using a multisite install for several sites and for some reason your script doesn't want to compress the JS files. It seems to work fine on the single site installs but not sure why. it seems that it will do some of the files on some sites and none on others. Any ideas?

    Thanks again,
    Brent

  4. mneil
    Member
    Plugin Author

    Posted 1 year ago #

    There currently aren't any filters to help you get done what you need but it's an idea for the next release. That means you'll have to modify the plugin files themselves. But, next time I release an update it can overwrite your changes if you upgrade so you'll want to make a back-up of any changes you make.

    In class-plugin-mncombine.php, line 800 starts the loop to combine/compress the files. The variable $data stores the file info. You could inject the data of your external files there. However, lines 804 to 807 check that the file exists locally so you'll need to conditionally skip those lines for those files.

    Pretty much the same thing needs to be done on line 1053 where I loop the css. Hopefully from there you can figure out a way to code in the external scripts. Obviously this will be much easier if I had included a filter.

    I have not tested with a multi-site install. The plugin searches for the files that belong to the active theme and not in for files in other themes so that could be why some work and others do not in a multi-site environment.

    Good luck, let me know what you come up with!

  5. mneil
    Member
    Plugin Author

    Posted 12 months ago #

    I am marking this as resolved. I will update when I roll out a filter. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.