views:

310

answers:

2

Hi php wordpress people,

I'm using inline editor plugin for wordpress I am aware that for seo purposes it is best to make sure these are external files. When I view the source in my browser I can see the javascript for inline editor plugin is displayed in the page code.

Is there a way to make this an external js file, within the wordpress framework, or will it have to be within the page for the plugin to work?

thanks for your help

Regards judi

Anyone know where this is comming from? I don't see it on my other websites so it must be from a different plugin?

<script type="text/javascript">
/* <![CDATA[ */
    var ileNicEditor;
    function startEditing(postId) {
        jQuery("#ileEditLink"+postId).hide(); 
        jQuery("#ileEditButton-"+postId).hide();
        jQuery("#ileCancelButton-"+postId).show();
        ileCreateNicEditor(postId);
    }
    function ileCreateNicEditor(postId) {
        jQuery.ajax({async:false,
                     type:"POST",
                     url:"http://fr.com/wp-content/plugins/inline-editor/ajax-content.php",
                     data:"id="+postId,
                     success:function(data){
                        jQuery("#ileContent-"+postId).html(data);
                     }
                     });
        ileNicEditor = new nicEditor({fullPanel:true,
                                      iconsPath:"http://fr.com/wp-content/plugins/inline-editor/nicEditorIcons.gif",
                                      onSave:function(content,id,instance){ileSave(postId,content)}
                                     }).panelInstance("ileContent-"+postId,{hasPanel:true});;
        jQuery("#ileCancelButton"+postId).show();
    }
    function ileSave(postId,content){
        jQuery.post("http://fr.com/wp-content/plugins/inline-editor/ajax-save.php",
                    {"id":postId,
                     "content":content},
                     function(data){
                         alert(data.message)
                         jQuery("#ileCancelButton-"+postId).click();
                     },
                     "json");
    }
/* ]]> */

</script>
A: 

It looks like you're asking if WordPress can handle using an external JS file instead of embedding it between script tags. If that's your question, then yes, just open your theme's header.php and include the file using:

<script src="http://other-site.com/script.js" type="text/javascript"></script>

Same as any other script include. WordPress will work fine with that.

Mike Crittenden
Yes but the code isn't in the theme its in the plugin?
judi
I know how to create external files for the theme, but why does the plugin add it in the page when i view the source in a browser?
judi
A: 

This will be caused by the way the author of the plugin has wrote it, the simplest option would be to get in touch with the author and see if the plugin is still maintained and ask if they would consider moving the javascript to an external stylesheet.

If you want to do it yourself then there would be no reason why you could not remove the inline code and create an external javascript file to include in the page but this would require you to feel confident with modifying the plugin as there is no easy way for wordpress to move it to an external stylesheet.

Mike