Title: reduce scripts output
Last modified: August 21, 2016

---

# reduce scripts output

 *  Resolved [yezzz](https://wordpress.org/support/users/yezzz/)
 * (@yezzz)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/reduce-scripts-output/)
 * Hi Hans,
 * I’m currently trying to speed up my site and I see wp-greet outputs its scripts(
   jquery, timepicker, datepicker, thickbox, smilies) and related css to the head
   of every page, slowing down pageload (and a potential cause for conflicts).
 * If I’m correct the ngg/slideshow integration is php only (hooks), so wp-greet
   only uses the above scripts on the form/card page.
 * Is it possible to move the wp enqueue scripts etc. to the code that outputs the
   form/card, perhaps use the shortcode to add the code to the head?
 * Thanks,
    Danny
 * [https://wordpress.org/plugins/wp-greet/](https://wordpress.org/plugins/wp-greet/)

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/reduce-scripts-output/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/reduce-scripts-output/page/2/?output_format=md)

 *  Plugin Author [tuxlog](https://wordpress.org/support/users/tuxlog/)
 * (@tuxlog)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/reduce-scripts-output/#post-5040941)
 * Please recheck with version released this morning. Should be partly better.
 *  Thread Starter [yezzz](https://wordpress.org/support/users/yezzz/)
 * (@yezzz)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/reduce-scripts-output/#post-5040946)
 * Ah I totally missed the update. Will have a look. thanks.
 *  Thread Starter [yezzz](https://wordpress.org/support/users/yezzz/)
 * (@yezzz)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/reduce-scripts-output/#post-5041056)
 * I’m seeing the following script src on non-card pages:
 * [http://example.com/wp-content/plugins/wp-greet/smilies_tinymce.js](http://example.com/wp-content/plugins/wp-greet/smilies_tinymce.js)
 * Maybe you removed one of the other smiley scripts?
 *  Plugin Author [tuxlog](https://wordpress.org/support/users/tuxlog/)
 * (@tuxlog)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/reduce-scripts-output/#post-5041101)
 * Will check this
 *  Plugin Author [tuxlog](https://wordpress.org/support/users/tuxlog/)
 * (@tuxlog)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/reduce-scripts-output/#post-5041112)
 * should be resolved with v4.5
 *  Thread Starter [yezzz](https://wordpress.org/support/users/yezzz/)
 * (@yezzz)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/reduce-scripts-output/#post-5041114)
 * Thanks! Will check it out.
 *  Thread Starter [yezzz](https://wordpress.org/support/users/yezzz/)
 * (@yezzz)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/reduce-scripts-output/#post-5041123)
 * Sorry for the late reply.
 * It’s working fine and looks like my site got a little speed boost. Great job!
 * The only improvement would be if you also stop wp-greet.css from being added 
   to every page.
 *  Thread Starter [yezzz](https://wordpress.org/support/users/yezzz/)
 * (@yezzz)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/reduce-scripts-output/#post-5041126)
 * Could you please make wp greet only output its stylesheet only where it’s needed?
 * It’s all over the place and my cardstyler is using it, making it rather large.
 * I could use the feature to turn of the css, but I don’t want to put it as inline
   style, so I would have to go scripting to add it. Can it be done with php inside
   the templates, or would that be outside the scope of the page/header?
 *  Plugin Author [tuxlog](https://wordpress.org/support/users/tuxlog/)
 * (@tuxlog)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/reduce-scripts-output/#post-5041127)
 * Well, I tried before but wasn’t succesful.
    How to manage this if you are on 
   a start page showing several post excerpts and one post has the form in it?
 * Any ideas?
 *  Thread Starter [yezzz](https://wordpress.org/support/users/yezzz/)
 * (@yezzz)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/reduce-scripts-output/#post-5041128)
 * Hmm no idea. I thought you were using the shortcode to enqueue the scripts, which
   I thought could also be done with enqeueing the stylesheet.
 * I do know [link library](https://wordpress.org/plugins/link-library/) only places
   css when needed, and in the settings you can even specify other pages to load
   scripts and styles. I think it’s based on page id’s.
 * Also maybe these pages are useful:
    [http://scribu.net/wordpress/optimal-script-loading.html](http://scribu.net/wordpress/optimal-script-loading.html)
   [http://mikejolley.com/2013/12/sensible-script-enqueuing-shortcodes/](http://mikejolley.com/2013/12/sensible-script-enqueuing-shortcodes/)
   [http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/](http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/)
 * Otherwise it will have to be something like this: [http://stackoverflow.com/questions/2685614/load-external-css-file-like-scripts-in-jquery-which-is-compatible-in-ie-also/2685639](http://stackoverflow.com/questions/2685614/load-external-css-file-like-scripts-in-jquery-which-is-compatible-in-ie-also/2685639)
 *  Thread Starter [yezzz](https://wordpress.org/support/users/yezzz/)
 * (@yezzz)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/reduce-scripts-output/#post-5041129)
 * I’m no php programmer at all, but I got “the sensible method” on that mikejolly.
   com page working, with enqueue style. Took about 10 minutes to set up.
 * Note to others reading this: do not hardcode the url like I do below. Read the
   function reference in the codex on how to do it properly.
 * Anyway, here’s what I did for testing:
 * Added this to my functions file:
 *     ```
       add_action( 'wp_enqueue_scripts', 'add_wpgreet_stylesheet' );  
   
       function add_wpgreet_stylesheet() {
       wp_register_style( 'some-unique-name', 'http://example.com/testsheet.css' );
       }
       ```
   
 * Then added this to the form template, within php tags:
 *     ```
       wp_enqueue_style('some-unique-name');
       ```
   
 * Then placed a stylesheet with some basic styling on [http://example.com/testsheet.css](http://example.com/testsheet.css)
 * And that’s all. Opened the form page and the stylesheet is present on the form
   page only.
 * I guess then you should be able to make it work on all templates via the shortcode.
 *  Thread Starter [yezzz](https://wordpress.org/support/users/yezzz/)
 * (@yezzz)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/reduce-scripts-output/#post-5041130)
 * On second thought, it would be useful if the plugin would only do the the registering
   part, and I could do the enqueueing manually via the templates. I’m considering
   to use a single url for the ecard “frontpage” and the ecard form/preview/display
   page, and would be preferable to only load the css with the form etc.
 * I think that should work with the following code in the form template:
 *     ```
       <?php if(!count($_GET)) {
       //or maybe only exclude wpgreet url parameters
       ?>
       //place frontpage html here
       <?php
       }else{
       // enqueue style + all template code here
       }
       ?>
       ```
   
 * Then also enqueue style in the other templates.
 * Hope you can make this possible, perhaps with the disable css rules option.
 *  Plugin Author [tuxlog](https://wordpress.org/support/users/tuxlog/)
 * (@tuxlog)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/reduce-scripts-output/#post-5041131)
 * Great to hear hear you have found a solution. I am not convinced of putting this
   kind of code in the template. Looks like it will produce lots of support mails
   when someone changes the templates.
 * But it seems to be perfect for you.
 *  Thread Starter [yezzz](https://wordpress.org/support/users/yezzz/)
 * (@yezzz)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/reduce-scripts-output/#post-5041132)
 * Well, my suggestion is: change the plugin to register the stylesheet like above,
   then where you currently enqueue the css, use the above enqueue method if “disable
   wp-greet css rules” checkbox is not ticked. Then it will simply behave the same
   way it does now, ie. it outputs the css on every page.
 * If that css checkbox is ticked, don’t enqueue the stylesheet, which is also the
   same way the plugin behaves now, ie. not output the css anywhere. The only difference
   is that the stylesheet is registered.
 * The webmaster then has a choice of how to put css on the page, eg. enqueue as
   above, add via script, style-tags, or whatever. And rookies don’t have to figure
   out stuff about functions files, manually adding things etc. Best of both worlds.
 *  Thread Starter [yezzz](https://wordpress.org/support/users/yezzz/)
 * (@yezzz)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/reduce-scripts-output/#post-5041134)
 * I had hoped you would release v4.7, even without the feature request above. The
   last v4.7 you sent worked great, and I could have installed it, but I prefer 
   to use WP built-in updater.

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/reduce-scripts-output/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/reduce-scripts-output/page/2/?output_format=md)

The topic ‘reduce scripts output’ is closed to new replies.

 * ![](https://ps.w.org/wp-greet/assets/icon-128x128.png?rev=1315506)
 * [wp-greet](https://wordpress.org/plugins/wp-greet/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-greet/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-greet/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-greet/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-greet/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-greet/reviews/)

 * 19 replies
 * 2 participants
 * Last reply from: [yezzz](https://wordpress.org/support/users/yezzz/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/reduce-scripts-output/page/2/#post-5041142)
 * Status: resolved